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.
Saved automatically
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.
Related Questions in JavaScript & Web Technologies
Explain the JavaScript Event Loop, Call Stack, Microtask, and Macrotask Queues
Intermediate level • 425 views
What is a closure? Show a practical example.
Easy level • 2 views
How do let, const, and var differ in scope and reassignment?
Easy level • 1 views
How should fetch code handle HTTP errors and malformed JSON?
Medium level • 1 views
How do event bubbling and delegation help with a dynamic list of buttons?
Medium level • 1 views