class A {
data1 = 1;
constructor(){
this.data2 = 2;
}
test() { console.log(this) }
}
class B extends A {
constructor() {
super();
}
funcA() { this.test() }
funcB() { super.test() }
}
let foo = new B()
foo.funcA();
foo.funcB();
what’s the difference between funcA()
and funcB()
while calling, or they are exactly the same thing?
BTW, what’s the difference between data1
and data2
declared in and out the constructor, which is preferred