extends 继承
class A{
constructor(x) {
this.x=x;
}
say(){
console.log(this.x);
}
}
let a=new A(6);
a.say();//6
// B继承A
class B extends A{
constructor(x,y){//B 自己的构造函数 构造函数通过new 会生成实例
super(x,y);
//super(x),代表调用A的构造函数constructor(x)。 但是返回的是子类B的实例
//super()在这里相当于A.prototype.constructor.call(this)。 this指的是B
//super 之后才能使用this
this.y=y; //B自己的属性
}
}
let b=new B(5,9);
b.say(); //5
console.log(b.y)//9
class A{
constructor(x)