Consider example:
Animal = function(age) {
this.age = age;
};
Animal.prototyp e.sleep = function() {
alert("Animal Sleeping...");
};
Human = function(name, age) {
this.name = name;
this.age = age;
};
Human.prototype = new Animal();
Human.prototype .sleep = function() {
// How to call my parent sleep();
};
var h = new Human("Peter", 15);
h.sleep();
I want inside the sleep() method of Human class, call to its parent
sleep() method.
Any idea?
Thanks.
Animal = function(age) {
this.age = age;
};
Animal.prototyp e.sleep = function() {
alert("Animal Sleeping...");
};
Human = function(name, age) {
this.name = name;
this.age = age;
};
Human.prototype = new Animal();
Human.prototype .sleep = function() {
// How to call my parent sleep();
};
var h = new Human("Peter", 15);
h.sleep();
I want inside the sleep() method of Human class, call to its parent
sleep() method.
Any idea?
Thanks.
Comment