I'm a bit confused with timers in Javascript. I've been playing around with timers.
I'm confused with how the queuing process in asychronous events happen. I have read about the article about how asynchronous events are queud. But i find it hard to wrap my head around the queuing process.
Here's the code:
http://jsbin.com/iwahuf/2/edit
In the code that i have posted would the timers be queud in sequence. Wouldn't the timers in the event queue be executed FIFO (First In, First Out).
Here's what i have in mind in the event queue.
- First Timer w/ 500ms delay
- Second Timer w/ 600ms delay
- Third Timer w/ 300ms delay
- Fourth Timer w/ 400ms delay
In my opinion, since the first timer has been the first to be registered in the Event queue, it will be the first to be executed and only after 500ms will the second timer be executed and so on.
Please enlighten me on this matter. I'm a litte confused. I think my understanding of the queuing process is not quite right.
Thanks in advance.