All topics
Asyncintermediate

Promises Fundamentals

The Promise object representing an eventual result of an asynchronous operation, with its three states and chaining behavior.

A Promise is an object representing the eventual completion (or failure) of an asynchronous operation, and it was introduced specifically to replace nested callbacks with a flatter, more composable structure. Because virtually all modern async JavaScript is built on Promises, this is one of the most foundational and frequently tested topics in any JS interview.

A Promise is like a ticket you get at a dry cleaner: not the cleaned clothes yet, just a guarantee you'll either get them back or be told something went wrong.

Key Concepts

1
A Promise exists in exactly one of three states: pending, fulfilled, or rejected. Once a promise settles, it is permanently locked into that state and value, which is what makes promises reliable to reason about compared to raw callbacks.
pendingfulfilledrejected
2
You consume a promise's eventual value with .then(onFulfilled, onRejected) and .catch(onRejected). Critically, .then() always returns a new promise, enabling chaining: returning a plain value fulfills the next promise with that value, returning another promise causes the chain to wait for it, and throwing causes the next promise to reject.
.then(onFulfilled, onRejected).catch(onRejected).then()
3
Promise.resolve(value) and Promise.reject(reason) create already-settled promises directly. Understanding these fundamentals is the prerequisite for async/await, Promise.all, and the microtask queue's execution order.
Promise.resolve(value)Promise.reject(reason)