Facebook Pixel

What is the output of console.log('1'); Promise.resolve().then(() => console.log('2')); console.log('3')?

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.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Promise Interview Questions in JavaScript

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.

Promise.all rejects if any promise rejects (fast fail). Promise.allSettled waits for all promises, even if some reject, and returns an array of { status, value/reason } objects.

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.