EasyEvent Loop & Promises💻 Output Question

Synchronous code runs before setTimeout

💡

Hint

All sync code finishes before any macrotask (setTimeout) runs — even with 0ms delay.

What does this output?

console.log('1');
setTimeout(() => console.log('2'), 0);
console.log('3');

Correct Output

1
3
2

Why this output?

Explanation: Synchronous code runs first (1, 3). setTimeout callbacks are macrotasks — they run after all synchronous code.

Key Insight: All sync code finishes before any macrotask (setTimeout) runs — even with 0ms delay.

More Event Loop & Promises Output Questions

MediumPromise microtask before setTimeout macrotaskMediumPromise chain passes valuesHardTwo Promise chains interleave in microtask queueMediumawait suspends function — caller continues

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz