Please take a look at the TypeScript snippet provided below:
class A {
value = 20;
func1(){
console.log("parent > " + this.value);
}
}
class B extends A {
value = 10;
func1(x?:number){
console.log("child > " + this.value);
super.func1();
}
}
let C = new B();
C.func1();
After executing the compiled code in Chrome, it seems to output child = 10 and parent = 10 .
What is the correct method for accessing parent class properties from the child class as the keyword this
does not appear to function properly.