class A {
constructor() {
this.x = 1;
}
setX() {
this.x = 2;
}
}
class B extends A {
getX() {
console.log(a.x);
}
}
class C extends B {
constructor() {
super();
}
setX() {
a.x = 3;
}
getX() {
console.log(a.x);
}
}
const a = new A();
a.setX();
const b = new B();
b.getX(); // 2
const c = new C();
c.setX();
c.getX(); // 3