HardEvent Loop & Promises💻 Output Question

throw inside .then becomes rejection, caught by .catch

💡

Hint

throw inside .then = return Promise.reject(). Errors propagate down the chain until a .catch handles them.

What does this output?

Promise.resolve('ok')
  .then(() => { throw new Error('oops'); })
  .catch(e => e.message)
  .then(msg => console.log(msg));

Correct Output

oops

Why this output?

Explanation: throw inside .then converts to rejected Promise. .catch handles it and returns e.message. Next .then receives "oops".

Key Insight: throw inside .then = return Promise.reject(). Errors propagate down the chain until a .catch handles them.

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