How JavaScript Timers Work [ejohn.org]