In a previous example, “Creating timers using the setInterval() method”, we saw how you can create a repeating timer using the setInterval() method.
In the following example, you will see how to create and cancel non-repeating timers using the setTimeout() and clearTimeout() methods. You’ll also see how you can pass additional parameters to the setTimeout() method which will get passed along to your custom function.
As pointed out by a keen reader in the previous example, the setInterval() and setTimeout() methods are the non-preferred methods of timers. The new and improved method is to use the Timer class.
Full code after the jump.
Continue reading ‘Creating timers using the setTimeout method’



