Clearing of intervals on page refresh

Hey, can anyone explain me the behaviour of setInterval. According to w3schools( https://www.w3schools.com/jsref/met_win_setinterval.asp ), setInterval() repeatedly calls a function after an interval of time until either clearInterval is called or window is closed. I had a question, whether the interval gets cleared on page refresh as well?

It’s recommend to clear it…because of cache memory

When you refresh a page, it is as if you had closed and reopened the window. Any scripts on the page that were previously running are instantly stopped, and everything starts over again from scratch. This makes dealing with the refresh button lots of “fun” in single-page apps, and a great many don’t handle it gracefully either.

Cache has nothing whatsoever to do with any of this BTW.

3 Likes