call(back)

What Are the States of a Promise?

What are the states of a promise? How do then, catch and finally behave?

Answer out loud in under a minute: a definition, one concrete example, and one pitfall or trade-off.

Hints

Hint 1

Say what "settled is final" means for a second resolve, and when a handler on an already-settled promise runs.

Solution

Show the approach

Answer

Pending, then fulfilled or rejected, and settled is final: a later resolve or reject is ignored. then, catch and finally each return a new promise, which is what makes chaining work. Handlers always run as microtasks, never synchronously, even on an already-settled promise. finally sees neither the value nor the reason, and passes the original outcome through unless it throws.

Promise sequencing in code is Run Promises in Sequence.

Assistant

Sign in to use the assistant — ask what the problem means, get a hint when you're stuck, or have your current work reviewed. Conversations save to your account.

Asked at

Similar Problems6