MediumEvent Loop & Promises💻 Output Question

Promise executor runs synchronously

💡

Hint

The Promise constructor executor is synchronous. Only .then callbacks are asynchronous.

What does this output?

console.log('a');
new Promise(resolve => {
  console.log('b');
  resolve();
}).then(() => console.log('c'));
console.log('d');

Correct Output

a
b
d
c

Why this output?

Explanation: The executor function runs synchronously (b logs immediately). resolve() schedules .then as a microtask. d logs sync. Then microtask: c.

Key Insight: The Promise constructor executor is synchronous. Only .then callbacks are asynchronous.

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