Home > Article > Web Front-end > What are the key states and terms in JavaScript promises?
The Intricate Terminology of JavaScript Promises
The world of JavaScript promises encompasses a myriad of terms that can leave developers perplexed. To navigate this maze, let us elucidate the precise meanings behind these key phrases.
Pending, Fulfilled, and Rejected
There exist three fundamental states for a promise:
Settled vs. Resolved
The term settled encompasses both fulfilled and rejected states, indicating that the promise is no longer pending. Resolved, however, conveys that the promise has left the pending state, but it does not definitively signify whether it is fulfilled or rejected.
Resolve and Rejection
Resolve initiates the process of settling the promise's fate. This transition can result in three possibilities:
Deferring
Deferring entails providing an asynchronous promise for a result rather than delivering the result synchronously. Additionally, a deferred rejection is returned instead of raising a synchronous exception. Note that the term "defer" may also refer to the method name used in some libraries to create a Deferred object.
The above is the detailed content of What are the key states and terms in JavaScript promises?. For more information, please follow other related articles on the PHP Chinese website!