What is the difference between .then's second argument and .catch in JavaScript?
.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.
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
