Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

定时器清除 #12

Open
HelenHai opened this issue Aug 3, 2021 · 0 comments
Open

定时器清除 #12

HelenHai opened this issue Aug 3, 2021 · 0 comments

Comments

@HelenHai
Copy link
Owner

HelenHai commented Aug 3, 2021

调用定时器会返回一个整型数字,代表了该定时器的序号。可以利用定时器的序号对定时器进行清除。

定时器不会自动销毁,所占内存无法自动回收,需要手动清理

const timer = setTimeout(()=>{}, 1000)
timer // 返回一个整形数组,例如:33

// 清除定时器
clearTimeout(timer)
clearInterval(timer2)

References

  1. JS设置定时器和清除定时器
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant