class A {
constructor() {
this.x = 1;
this.print=()=>{
console.log(this.x+'A instance');
}
}
static x=2
static print() {
console.log(this.x+'A static');
}
print() {
console.log(this.x+'A prototype');
}
}
A.prototype.x=3;
class B extends A {
constructor() {
super();
this.x = 9;
//super.x = 10;
this.m=()=>{super.print()};
//console.log(super.x); // undefined
//console.log(this.x); // 3
}
static x=20
static m() {
super.print();
}
m() {
super.print();
}
}
B.prototype.x=30;
let b = new B();
b.m();
B.m();
B.prototype.m();
prototype就是用来溯源的;this看引用的对象;两者应分开查找。