• A prototype is a property of every JavaScript object
• Functions and properties can be associated with a
constructor’s property
• When a function is invoked with new keyword, all
properties and methods of the prototype for the
function are attached to the resulting object

var MyObj = function(name, size){
    this.name = name;
    this.size = size;
}

MyObj.prototype.tellSize = function(){
    alert("size of " + this.name + "is" + this.size);
}

var myObject = new MyObj("Sang", "30 Inches");
myObject.tellSize();
Advertisements