MediumEvent Loop & Promises💻 Output Question

Promise.all preserves order

💡

Hint

Promise.all preserves input order in results regardless of which promise resolves first.

What does this output?

Promise.all([
  Promise.resolve(1),
  Promise.resolve(2),
  Promise.resolve(3),
]).then(values => console.log(values.join(',')));

Correct Output

1,2,3

Why this output?

Explanation: Promise.all waits for all and resolves with an array of values in the original order.

Key Insight: Promise.all preserves input order in results regardless of which promise resolves first.

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