Promise States
pending, fulfilled and rejected states of Promises
We'll cover the following
Promises represent the eventual result of an asynchronous operation. They give us a way to handle asynchronous processing in a more synchronous fashion. A promise represents a value we can handle in the future, with the following guarantees:
- Promises are immutable.
- Promises are either kept or broken.
- When a promise is kept, we are guaranteed to receive a value.
- When a promise is broken, we are guaranteed to receive the reason why the promise cannot be fulfilled.
Promise States
pending
: may transition tofulfilled
orrejected
fulfilled
(kept promise): must have a valuerejected
(broken promise): must have a reason for rejecting the promise
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.