To help us better understand the setTimeout method we will explore the function itself and also build a sample application.
The sample application is really simple. Pressing the change color button will disable the button and start a timer. At the end of the timer the button will be re-enabled and the box in the center of the screen will change color. The timeout will be on a 2 second delay. To cancel the timer we will have a cancel button which will invoke the clearTimeout method passing in the timerID.
Top comments (0)