Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
Stolen from Crockford's Good Parts. When the code returns 'this', what does 'this' reference in this case?
I always ask myself this when I see 'this' inside a js code because I know that js is funky with the word this (i.e. 'this' actually references the global variable when it is used inside a nested function)