Mega Code Archive

 
Categories / JavaScript Tutorial / Object Oriented
 

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();