Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

setTimeout guarantees that the time provided is the time that has at least been elapsed, if it elapses at all - I think that is known to every JavaScript engineer out there.

Then there are also gotchas like these[0][1]:

> As specified in the HTML standard, browsers will enforce a minimum timeout of 4 milliseconds once a nested call to setTimeout has been scheduled 5 times.

Still, the issue is rather how to measure the elapsed time reliably, for unit-tests among other things.

[0]: https://developer.mozilla.org/en-US/docs/Web/API/Window/setT...

[1]: https://html.spec.whatwg.org/multipage/timers-and-user-promp... (first Note)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: