Does setTimeout(cb, 1000) guarantee the callback runs after exactly 1000ms?
No. It guarantees a minimum of 1000ms. The actual delay depends on the call stack, microtask queue, background tab throttling, and nested timer clamping. The callback runs at least after 1000ms, but often later.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in setTimeout Interview Questions: Trust Issues in JavaScript
4ms after 5 nested levels. The HTML spec specifies this to prevent abuse. The first 5 levels can use 0ms, but after that, the delay is clamped to 4ms.
No. The callback never runs before the delay. It may run later (if the stack is busy, microtasks are queued, or the tab is in the background), but never earlier.
The delay is treated as 0. The callback goes to the macrotask queue and runs after the call stack is empty and all microtasks are done.
Still have questions?
Browse all our FAQs or reach out to our support team
