Skip to content

24 ways to impress your friends

Vote down?

Stephen Band

@Mike Morici

1] setTimeout(fn, 0); sets up a timer. Timers fire as soon as they can. In this case, if the JavaScript engine is busy working on something, the timer is queued to fire as as soon as it becomes available. It’s like saying, “Let everything else finish, and then do this”. It’s a neat technique for waiting for other event handlers do what they have to do, before running your function.

2] It isn’t.