Lately I\'ve become a huge fan of the function.name property.
For example, I\'ve written a function for extending prototypes.
It works in the w
I think your .give() solution is a little..verbose. What's wrong with:
Array.prototype.forEach = function () { ... };
?
Really, though, you should check for such a method's existence before supplying your own:
Array.prototype.forEach = Array.prototype.forEach || function () { ... };
Since others will be led here wondering about function.name, there is a way to grab the name (obviously, it doesn't work on anonymous functions):
function getFnName(fn) {
return (fn.toString().match(/function (.+?)\(/)||[,''])[1];
}