Jan 24
Meh;
var Dog = function() {
this.say = function( name ) {
return name;
}
};
var Animal = function() {
this.inherit = Dog;
this.inherit();
};
var pet2 = new Animal();
pet2.say("bob");
Something about writing on a whiteboards.
Of course, there’s load of different ways you could write this, meh.
From this example it seems you haven’t understood the inheritance concept in Javascript. Please review the code and I’m sure you will find the mistake.
Why? Because I haven’t written it out with a proper construct method?
I should probably change the title to ‘quick and dirty inheritance’.
I need to write an article about class inheritance in JavaScript when I’ve got the time, there’s not enough hours in the day though