只有运行结果吗?
当没有写extends时
class Father {
say(){
return '父类 '
}
}
class Son{
say(){
console.log('儿子');
//super.say() 就是调用父亲中的函数 say()
}
}
var son = new Son()
son.say()//儿子
当有extends时,就近原则
class Father {
say(){
return '父类 '
}
}
class Son extends Father{
say(){
console.log('儿子');
}
}
var son = new Son()
son.say() //儿子
super的注意点
super必须放在子类中的this之前