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()
运行结果