Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to kill a setTimeout() function

I use the setTimeout() function through my application but when its time to garbage collect. the method still runs and calls on a function. How do I stop it from calling on a certain function. I tried setting it to null but it doesnt work

like image 841
numerical25 Avatar asked Feb 03 '10 22:02

numerical25


1 Answers

setTimeout returns an reference to the timeout, which you can then use when you call clearTimeout.

var myTimeout = setTimeout(...);
clearTimeout(myTimeout);
like image 176
Matt Huggins Avatar answered Sep 23 '22 04:09

Matt Huggins