简体   繁体   English

Javascript - setInterval()

[英]Javascript - setInterval()

I am making a game using Javascript, and to update the game I am using setInterval(). 我正在使用Javascript制作游戏,并使用setInterval()更新游戏。 Should I use clearInterval() somehow on the window exit, or does it automatically stop? 我应该在窗口出口处以某种方式使用clearInterval(),还是会自动停止?

The browser is (or better: should be) clever enough to fully clean up a closed website. 浏览器(或更好:应该)足够聪明,可以完全清理已关闭的网站。 That includes aborting it's running connections and terminating scripts. 这包括中止它正在运行的连接和终止脚本。 Data that stays on your PC after you close the tab usually only includes stuff like browser history entries, cookies, local storage and cached data (eg scripts, stylesheets, images). 关闭选项卡后保留在PC上的数据通常只包括浏览器历史记录条目,cookie, 本地存储和缓存数据(例如脚本,样式表,图像)等内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM