What is the output of Promise.resolve(1).then(n => { n + 1; }).then(n => console.log(n))?
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.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Promise Chaining Interview Questions in JavaScript
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.
.then(onFulfilled, onRejected) second arg only catches rejections from the original promise. .catch catches rejections from the original promise AND thrown errors from any .then above it. .catch is more comprehensive.
Still have questions?
Browse all our FAQs or reach out to our support team
