1//single event i.e. alarm, time in milliseconds
2var timeout = setTimeout(function(){yourFunction()},10000);
3//repeated events, gap in milliseconds
4var interval = setInterval(function(){yourFunction()},1000);
1Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time.
2This is done by using the functions
31. setTimeout
42. setInterval
53. clearInterval
6
7The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay.
8The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled.
9The clearInterval(id) function instructs the timer to stop.