then 1. .catch only runs on rejection. Since the promise is fulfilled (resolve(1)), .catch is skipped, and .then receives 1.
What is the output of Promise.resolve(1).catch(e => 'catch').then(n => console.log(n))?
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
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.