Example from: "Javascript - The Good Parts"

Posted by Matrym on Stack Overflow See other posts from Stack Overflow or by Matrym
Published on 2010-06-01T06:39:09Z Indexed on 2010/06/01 6:43 UTC
Read the original article Hit count: 243

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about function