freeCodeCamp/guide/english/javascript/window-cleartimeout-method/index.md

798 B

title
Window clearTimeout Method

Window clearTimeout Method

The 'clearTimeout()' method is used stop a timer set with the 'setTimeout()' method.

    clearTimeout(setTimeout_ID); 

If the 'clearTimeout()' method is called before the timer has finished counting, the 'clearTimeout()' method will stop the 'setTimeout()' method from executing.

To be able to use the 'clearTimeout()' method, you must use a global variable. See the example below

    myID = setTimeout(function, milliseconds); 

More Information:

Documentation: MDN