JavaScriptMedium
Explain the different states of a Promise
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
A Promise in JavaScript can be in one of three states: pending, fulfilled, or rejected. When a Promise is created, it starts in the pending state. If the operation completes successfully, the Promise transitions to the fulfilled state, and if it fails, it transitions to the rejected state. Here's a quick example:
js
let promise = new Promise((resolve, reject) => {
// some asynchronous operation
if (success) {
resolve("Success!");
} else {
reject("Error!");
}
});
