Sometimes, we want to reset setTimeout with JavaScript.
In this article, we’ll look at how to reset setTimeout with JavaScript.
How to reset setTimeout with JavaScript?
To reset setTimeout with JavaScript, we can call the clearTimeout
function.
For instance, we write
const myTimer = setTimeout(() => {
//...
}, 115000);
//...
clearTimeout(myTimer);
to call setTimeout
to return a timer ID number and run the function after 115000 milliseconds.
Then we call clearTimeout
with myTimer
to stop the timer.
Conclusion
To reset setTimeout with JavaScript, we can call the clearTimeout
function.