class Base {
setupServer(){
console.log("BaseClass")
}
listen() {
this.setupServer();
}
}
class Child extends Base {
setupServer() {
console.log("ChildClass")
}
}
const child = new Child();
child.listen();
Why does this print out: ChildClass
? I would expect this
in the Base
class to only see the setupServer
method in the same class. Is there a way to call the listen
function from the child instance and then still execute the Base
class setupServer()
method first without doing a super.setupServer()
in the Child class?