- Mastering JavaScript Promises
- Muzzamil Hussain
- 123字
- 2021-07-16 13:46:46
States of a promise
Promise is based on three states. Each state has a significance and can be used to drive a certain level of result as per the need. This can help a programmer choose as per his/her need. The three states of a promise are as follows:
- Pending: This is the initial state of a promise
- Fulfilled: This is the state of a promise representing a successful operation
- Rejected: This is the state of a promise representing a failed operation
Once a promise is fulfilled or rejected, it is immutable (that is, it can never change again).
With reference to the concepts discussed earlier, it's now clear what a promise is and how you can use it with all its potential.