Prototype Chaining : Inheritance : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » Inheritance »

 

Prototype Chaining









The downside to prototype chaining is that it has no support for multiple inheritance.

Prototype chaining involves overwriting the prototype property of the class with another type of object.

You can set the prototype property of SubClass to be an instance of BaseClass to inherit all the properties and methods of BaseClass.








function BaseClass() {
}

BaseClass.prototype.color = "red";
BaseClass.prototype.sayColor = function () {
    alert(this.color);
};

function SubClass() {
}

SubClass.prototype = new BaseClass();







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» Inheritance