Promise
In one line
A promise is an object representing the eventual result of an asynchronous operation — success or failure.
In simple words
A promise is JavaScript's way of saying "I do not have the answer yet, but I will eventually." It is an object that holds the state of an async operation: pending (still waiting), fulfilled (succeeded with a value), or rejected (failed with an error).
You consume a promise with .then() (runs on success), .catch() (runs on failure), and .finally() (runs either way). Promises can be chained: each .then() returns a new promise, so you can sequence async steps without nesting.
Promises were introduced to solve callback hell. Instead of passing callbacks deep into functions, you call an async function, get a promise back, and chain .then() calls linearly. async/await builds on promises to make async code look even more like synchronous code.
Example
fetch("https://api.example.com/user")
.then((response) => response.json())
.then((user) => console.log(user.name))
.catch((error) => console.error("Failed:", error));fetch returns a promise. .then() chains run on success; .catch() handles any error in the chain.
How it works
- An async operation creates a promise in the pending state.
- When the operation succeeds, the promise is fulfilled with a value.
- If it fails, the promise is rejected with a reason (error).
.then(onFulfilled)runs when the promise fulfills..catch(onRejected)runs when the promise rejects.
Common confusions
Confused with: callback
The difference: A callback is a function passed to be called later; a promise is an object representing a future value. Promises are chainable and have a single resolution, while callbacks can be called multiple times.
Related terms
Related Resources
Related Lessons
- Async JavaScript
Promises, async, and await
Learn the fundamentals
Deepen your understanding with structured lessons on this topic.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.