What is the difference between .then, .catch, and .finally in JavaScript promises?
.then runs when the promise fulfills. .catch runs when the promise rejects (or a .then throws). .finally runs when the promise settles (fulfilled or rejected), regardless of outcome. .finally does not receive the value or error.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in What Are Promises in JavaScript?
An object representing the eventual result of an async operation. It is a placeholder for a future value. A promise has three states: pending, fulfilled, and rejected. It settles (fulfills or rejects) exactly once.
Pending (initial, not yet settled), fulfilled (operation succeeded, has a value), and rejected (operation failed, has a reason/error). A promise transitions from pending to fulfilled or rejected once and cannot change state after settling.
Use new Promise((resolve, reject) => { ... }). The executor function runs immediately. Call resolve(value) to fulfill the promise, or reject(reason) to reject it. The executor usually starts an async operation.
Still have questions?
Browse all our FAQs or reach out to our support team
