Verified Jobs Live
JavaScript & Web Technologies Medium Level ~3 min read

What is the output of synchronous code, a resolved promise, and setTimeout with zero delay?

Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Model Answer & Deep-Dive Explanation

The synchronous statements run first. A promise reaction runs as a microtask after the current task completes, before the next eligible timer task. A zero-delay timer does not mean immediate execution and may be delayed by other work or browser scheduling rules. In this example the output is start, end, promise, timer. This explanation describes the ordinary browser execution model; environments such as Node.js have additional scheduling details. An expensive synchronous loop still blocks this sequence because adding promises does not move CPU work off the thread.