The 2 method can be used for timing events –
1- setIterval() – it executes some events, over and over again some specified intervals.
window.setInterval() method can written without window prefix but first parameter of set interval should be a function. The second parameter indicated the time in milliseconds, on each time intervals this function called again and again.
2- setTimeout()– it executes some events, after some waiting time in milliseconds. This functions is only called once.
1000 ms = 1 sec
In this function will be called after some specified milliseconds. Both parameters are require d in set Timeout .
You can use the function clearTimeout() to cancel the setTimout() timer.