Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript timer implementation

Tags:

javascript

I am trying to find out exactly how JavaScript timers work. In particular whether a timer function is executed immediately the timer expires or instead when the JavaScript engine is in some kind of idle state.

For example if the JavaScript engine is executing a block of code and a timer goes off does the execution of the block of code get interrupted and the timer function called. Or does the JavaScript engine wait until it returns to some kind of idle state before it calls the timer function?

Thanks,

AJ

like image 262
AJ. Avatar asked Feb 05 '10 17:02

AJ.


1 Answers

Here's a very good explanation from John Resig

how-javascript-timers-work

like image 182
meouw Avatar answered Sep 21 '22 00:09

meouw