I have a class called person:
function Person() {}
Person.prototype.walk = function(){
alert ('I am walking!');
};
Person.prototype.sayHello = function(){
alert ('hello');
};
The student class inherits from person:
function Student() {
Person.call(this);
}
Student.prototype = Object.create(Person.prototype);
// override the sayHello method
Student.prototype.sayHello = function(){
alert('hi, I am a student');
}
What I want is to be able to call the parent method sayHello from within it's childs sayHello method, like this:
Student.prototype.sayHello = function(){
SUPER // call super
alert('hi, I am a student');
}
So that when I have an instance of student and I call the sayHello method on this instance it should now alert 'hello' and then 'hi, I am a student'.
What is a nice elegant and (modern) way to call super, without using a framework?