class Base {
serverSetup(){
console.log("BaseClass")
}
listen() {
this.serverSetup();
}
}
class Child extends Base {
serverSetup() {
console.log("ChildClass")
}
}
const child = new Child();
child.listen();
Why is the output ChildClass
? It seems like this
in the Base
class should only access the serverSetup
method in its own class. Is there a way to invoke the listen
function from the child instance and have it first execute the Base
class' serverSetup()
method without using super.serverSetup()
within the Child class?