this Keyword in Different Contexts
What demonstrates this code about 'this' in inheritance?
class Parent {
constructor() {
this.name = 'Parent';
}
getName() {
return this.name;
}
}
class Child extends Parent {
constructor() {
super();
this.name = 'Child';
}
}
const child = new Child();
console.log(child.getName());