extends
class Person {
constructor(name) {//构造函数
this.name = name
}
say() {
console.log(`hi,my name is ${this.name}`);
}
}
class student extends Person{
constructor(name,number){
super(name)//始终指向父类,调用super即调用父类的构造函数
this.number=number
}
hello(){
super.say()//调用父类的say方法
console.log(`my number is ${this.number}`);
}
}
let st=new student('xx',123)
st.hello()