What's the difference between using or not using prototype
? They apparently do the same.
With prototype
:
function poligon(angles){
this.angles = angles;
}
poligon.prototype.color = function(){ return "blue"; }
var mypol = new poligon(14);
alert(mypol.color());
Without prototype
:
function poligon(angles){
this.angles = angles;
}
poligon.color = function(){ return "blue"; }
var mypol = new poligon(12);
alert(poligon.color());
What does it really mean adding a "color" object with prototype
and without it?