Mega Code Archive

 
Categories / JavaScript Tutorial / Object Oriented
 

Function share with Prototype Paradigm

function Car() { } Car.prototype.color = "red"; Car.prototype.doors = 4; Car.prototype.drivers = new Array("M", "S"); Car.prototype.showColor = function () {     alert(this.color); }; var myHourse1 = new Car(); var myHourse2 = new Car(); myHourse1.drivers.push("M"); alert(myHourse1.drivers);     alert(myHourse2.drivers);