Facebook Pixel

Does .finally receive the value or error in JavaScript?

No. .finally does not receive the value or error. It runs for cleanup (hiding spinners, closing connections). The promise returned by .finally passes through the original value or error.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Promise .then, .catch, and .finally Explained

.then runs when the promise fulfills (receives the value). .catch runs when the promise rejects or a .then throws (receives the error). .finally runs when the promise settles, regardless of outcome (no value or error received).

Yes. Each .then (and .catch and .finally) returns a new promise. If the callback returns a value, the new promise fulfills with that value. If it returns a promise, the new promise waits for it. This enables chaining.

If a .then callback throws, the error skips subsequent .then callbacks and propagates to the next .catch. If there is no .catch, the error becomes an unhandled rejection. After .catch, the chain continues with the value returned by .catch.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.