What is the output of Promise.resolve(1).catch(e => 'catch').then(n => console.log(n))?
then 1. .catch only runs on rejection. Since the promise is fulfilled (resolve(1)), .catch is skipped, and .then receives 1.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Promise Chaining Interview Questions in JavaScript
undefined. The first .then has a block body (braces) with no return statement. Block bodies need an explicit return. Without it, the function returns undefined, and the next .then receives undefined.
No. .catch only runs on rejection or when a .then above it throws. If the promise is fulfilled, .catch is skipped and the next .then receives the value.
The chain continues as fulfilled with the value returned by .catch. If .catch returns 'recovered', the next .then receives 'recovered'. If .catch re-throws, the next .catch catches it.
Still have questions?
Browse all our FAQs or reach out to our support team
