I see only one case where I should use window.setTimeout instead of setTimeout, it is when I have reused the name setTimeout in my closure, which is obviously not so good a practice (unless very specific use).
I noticed that Google Closure compiler does not remove window.. Since it is so aggressive in reducing variable names, I wondered if they have any reason for that?
Is there any other reason I am missing?
If you use
window.setTimeout, you’re sure to usewindow.setTimeout. That might not be a case if thesetTimeoutvariable was shadowed in your scope.If you’re sure you didn’t shadow this variable, you might not bother, but the Closure compiler has no way to be sure, one of the reasons being that the context of a function can be provided dynamically.