What are the Different States and Fates of a JavaScript Promise?

Promise States

A JavaScript Promise can be in one of the following three mutually exclusive states:

  1. fulfilled: the operation completed successfully;
  2. rejected: the operation did not complete successfully (typically due to an error);
  3. pending: its future is still uncertain (i.e. it's neither fulfilled nor rejected).

A promise is said to be "settled" if it is not pending (i.e. if it is either fulfilled or rejected).

Being "settled" does not constitute to a state, but is rather meant as a hypernym for fulfilled and rejected.

Promise Fates

A JavaScript Promise has two possible mutually exclusive fates:

  1. resolved
  2. unresolved

A promise is considered resolved when:

  1. It has been either fulfilled or rejected, or;
  2. It has been "locked in" to follow another Promise — i.e. it was resolved with another pending promise and will now be waiting on the eventual state of it.

A promise is considered to be unresolved, simply when it has not resolved. An unresolved promise is always in the pending state, while a resolved promise may be pending (when "locked in" for example), fulfilled or rejected.

Hope you found this post useful. It was published . Please show your love and support by sharing this post.