I have come across an interesting behavior when playing around and trying to override Function
prototype.
Let\'s assume we have overriden toString() lik
This is a problem of a missing semicolon:
Function.prototype.toString = function() {
…
}; /*
^ */
(function foo(){}).toString();
Otherwise it is interpreted as
Function.prototype.toString = function(){…}(function foo(){}).toString();
which calls the function expression that is supposed to override toString
like an IIFE
… (function(){…}(function foo(){})) …
…in the global context, not on a function.