Timers
You can schedule specific callbacks using timer functions that are available globally.
setTimeout
Sometimes you might want to delay the execution of a function - you can use setTimeout
for this task.
setInterval
This function is similar to setTimeout
, but runs repeatedly.
clearInterval and clearTimeout
Sometimes you may want to cancel timers - you can easily do it with clearInterval
and clearTimeout
.
Both setInterval
and setTimeout
return numerical ID and we can use them to clear specific timers.