Facebook Pixel

Why does a .then with a block body and no return pass undefined in JavaScript?

Because arrow functions with block bodies (=> { ... }) need an explicit return. Without return, the function returns undefined, and the next .then receives undefined. Use an expression body (=> expr) or add return.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Promise Interview Questions in JavaScript

1, 3, 2. The .then callback is a microtask; it runs after the synchronous code (1 and 3) completes and the call stack is empty.

The error propagates to the next .catch in the chain. Subsequent .then callbacks are skipped. If there is no .catch, it becomes an unhandled rejection.

No. .catch only runs when the promise rejects or a .then above it throws. If the promise is fulfilled, .catch is skipped and the next .then receives the value.

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.