3:22am 17th January 2014
setTimeout are the global context (via
window object) methods. Then you close the tab or window all contexts will remove. Then you open new tab/window all contexts will created.
3:24am 17th January 2014
setInterval() method will continue calling the function until
clearInterval() is called, or the window is closed. Same goes for
setTimeout(). You can give settieout to open window after 3 seconds on close. click and close. You will see that window wont be popping up.
3:58am 17th January 2014
Both SetInterval() and SetTimeout() are a browser built-in schedulers. Which allows to setup function calls for execution after given period of time.
SetTimeout() can be cancelled by clearTimeout() method or on browser window closed.
SetInterval() method has same features as setTimeout. Which can be stopped by clearInterval call.
Functions used in setTimeout/setInterval are also referenced internally and tracked until complete, then cleaned up.