We can add functionality to whole hierarchy by changing the prototype, for example.
function Animal() {
var r = {};
return r;
}
var a = new Animal();
Object.prototype.greet = function() {
alert("hello");
};
a.greet();
No comments:
Post a Comment