Example from: "Javascript - The Good Parts"
- by Matrym
What "ugliness" does the following solve? There's something I'm not getting, and I'd appreciate help understanding what it is.
For example, by augmenting Function.prototype, we can make a method available to all functions:
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
By augmenting Function.prototype with a method method, we no longer have to type the name of the prototype property. That bit of ugliness can now be hidden.