I would like to know what the difference is between
window.setTimeout(myFancyFunciton, 1000);
and
setTimeout(myFancyFunciton, 1000);
Both seem to do the exact same thing. When should you use one or the other?
I would like to know what the difference is between
window.setTimeout(myFancyFunciton, 1000);
and
setTimeout(myFancyFunciton, 1000);
Both seem to do the exact same thing. When should you use one or the other?
Assuming we're talking about browser-based JavaScript: No difference. setTimeout() simply omits the window., which is implied. The effect they have is exactly the same.
It's a choice of coding style and preference.
For JavaScript that does not run in a browser, the window object is not defined, so window.setTimeout() will fail. setTimeout() however, will work.