i am playing a bit with some code snippets and i am asking if its possible to use a function that was defined in a child class (with extends), to use in a variable that was created with the parent class?
Here is my code snippet:
class Workshop {
constructor(teacher) {
this.teacher = teacher;
}
ask(question) {
console.log(this.teacher, question);
}
}
class AnotherWorkshop extends Workshop {
speakUp(msg) {
console.log(msg);
}
}
var shallowJS = new Workshop("Toby");
shallowJS.ask("you are there?");
shallowJS.speakUp("still there?");
Is there anyway, that i can access the function speakUp from the child class AnotherWorkshop with shallowJS.xxxx ? (and i dont mean the way to create a new variable of shallowJS)
Thanks a lot for help 🙂