Node.js Output Prediction Hard +35 XP
Event Loop Priority
In what order do these execute?
Node.jsRead-only
setTimeout(() => console.log("A"), 0);
Promise.resolve().then(() => console.log("B"));
console.log("C");What is the output?
Show answer and explanation
Answer: C B A
Sync code (C) runs first. Microtasks/Promises (B) run before macrotasks. setTimeout (A) is a macrotask — runs last.
Hint: Microtasks run before macrotasks.
What this challenge tests
Output Prediction in Node.js: event-loop, async.