Function share with Prototype Paradigm : prototype : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » prototype »

 

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







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» prototype