Mega Code Archive

 
Categories / JavaScript Tutorial / Object Oriented
 

Prototype Paradigm

Prototype Paradigm makes use of an object's prototype property. An empty constructor is used only to set up the name of the class. All properties and methods are assigned directly to the prototype property. function Car() { } Car.prototype.color = "red"; Car.prototype.doors = 4; Car.prototype.showColor = function () {     alert(this.color); }; var my1 = new Car(); var my2 = new Car();