What does .finally do in JavaScript promises?
It runs when the promise settles (fulfilled or rejected), regardless of outcome. It does not receive the value or error. Use it for cleanup: hiding spinners, closing connections, resetting state.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Promise Error Handling With .catch in JavaScript
It handles rejections from the original promise and thrown errors from any .then above it. .catch receives the error. After .catch, the chain continues with the returned value (recovery).
Yes. .catch catches both rejections from the original promise and errors thrown in any .then callback above it. This is why .catch is better than .then's second argument, which only catches rejections from the original promise.
Return a value from .catch. The chain continues as fulfilled with that value: .catch(err => 'fallback').then(result => render(result)). The .then receives 'fallback'.
Still have questions?
Browse all our FAQs or reach out to our support team
