Post Link : JavaScript timers With Examples
This tutorial explains how to use javaScript timers function. JavaScript features a handy couple of methods of the window object: setTimeout() and setInterval(). These let you run a piece of JavaScript code at some point in the future. If we want to delay the execution of Javascript code, then we need to use the time interval functions. These time intervals are called timing events. The block of JavaScript code is executed synchronously. But there are some JavaScript native functions (timers) which allow us to delay the execution and we can create an async kind of behavior.
Lets see the different type of timer function in javascript :
setTimeout allows to run a function once after the interval of time.
setInterval allows to run a function regularly with the interval between the runs.
clearTimeout will stop the current running timer function.
Top comments (0)