MediumEvent Loop & Promises💻 Output Question

Promise.then is always async — even when resolved

💡

Hint

Promise .then callbacks are ALWAYS asynchronous — guaranteed by the spec, even for already-resolved promises.

What does this output?

let x = 0;
Promise.resolve().then(() => { x = 1; });
console.log(x);

Correct Output

0

Why this output?

Explanation: Even though Promise.resolve() is already resolved, .then is always async (microtask). x is still 0 when synchronously logged.

Key Insight: Promise .then callbacks are ALWAYS asynchronous — guaranteed by the spec, even for already-resolved promises.

More Event Loop & Promises Output Questions

EasySynchronous code runs before setTimeoutMediumPromise microtask before setTimeout macrotaskMediumPromise chain passes valuesHardTwo Promise chains interleave in microtask queue

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz