I have an Object which called Rectangle :
function Rectangle(x, y) {
this.x = x;
this.y = y ;
this.surface = function(x, y) {
return x*y;
}
}
Rectangle.prototype.couleur = "Rouge";
and I have two instances of this Object :
r1 = new Rectangle(3, 5);
r2 = new Rectangle(4, 7);
Then I declared a third instance :
r3 = new Rectangle(6, 7);
and I want this instance to have a unique method :
afficheCouleur = function() {
return this.couleur;
}
I tried as this :
r3.prototype.afficheCouleur = function() {
return this.couleur;
}
But I got this error :
[11:32:40.848] TypeError: r3.prototype is undefined @ file:///media/tpw/760F-F396/vv:24