You can do it this way, or you can assign a new object to the prototype (overwriting any existing properties / methods):
Shape.prototype = {
foo : function(){
},
bar : function(){
}
};
If you're adding lots of methods to different prototypes and you don't want to overwrite the entire prototype object, define a helper method to do the asignment for you:
function addToPrototype(constructor, obj){
for (var prop in obj){
constructor.prototype[prop] = obj[prop];
}
}
addToPrototype(Shape, {
foo : function(){
},
bar : function(){
}
});
addToPrototype(Shape, {
something : function(){
}
});
addToPrototype(Polygon, {
somethingElse : function(){
}
});
prototypeproperty of a constructor.