前端学习笔记202309学习笔记第九十二天-this指向问题9
class Father{
constructor(){
this.age=18
}
swim(){
console.log("Go Swimming")
}
}
class Son extends Father{
constructor(){
super()
this.hobby="playing"
}
study(){
console.log(this)
this.swim()
}
}
const son=new Son()
son.study()
运行结果


浙公网安备 33010602011771号