I have two classes namely A and B respectively. The class definitions are as shown below.
class A {
constructor(){
...
}
...
}
//Implementation 1
class B extends A {
constructor(){
this.childProperty = "something"; // this is undefined.
}
}
//Implementation 2
class B {
constructor(){
this.childProperty = "something"; // this is not undefined.
}
}
Why is this
undefined in Implementation 1
and not in Implementation 2
? What am I doing wrong here?