Possible Duplicate:
Why does Twitter redefine window.setTimeout and window.setInterval?
I saw a code like that
window.a = 5;
(function() { window.a = window.a; })();
why should they do it like that? Why not just do
(function() { window.a = 5; })();
more example
(function() { window.setInterval = window.setInterval; })();
Isn’t it the same principle like above?
There is
novery little sense and use in doing that. I wouldn’t know what more to answer.As @RussellDias pointed out in a comment, there might be an pretty edgy edge case for IE7+8 (maybe also below) where it might be reasonable to re-assign native methods to itself.
See http://adequatelygood.com/2011/4/Replacing-setTimeout-Globally