Are equal timeouts executed in order in Javascript?

Viewed 3614

Suppose I do

setTimeout(foo, 0);

...

setTimeout(bar, 0);

Can I be sure foo will begin executing before bar? What if instead of 0 I use a timeout of 1, 10, or 100 for bar?

Simple experiments show that in the case of equal timeout values the timeout targets are executed in the same order as the setTimeouts themselves, but is it safe to rely on this behavior?

5 Answers
Related