Favorites

JavaScript Promise Object

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Promise
JavaScript Control Abstraction · ConstructorThis object is supported by all modern browsers.
Updated 28th November 2026

A Promise represents the result of an asynchronous operation that will finish later, such as a network request. It lets you handle the success or failure with then(), catch() or await.

Description

A Promise is an object that represents the eventual result of an asynchronous operation. Instead of passing callbacks into a function, the function returns a promise straight away, and you attach handlers that run when the result is ready. Functions such as fetch() return promises.

A promise is always in one of three states: pending while the work is in progress, fulfilled with a value when it succeeds, or rejected with a reason (usually an Error) when it fails. Once it is fulfilled or rejected it is "settled" and never changes again. Handlers are added with then(), catch() and finally(), each of which returns a new promise, so they can be chained.

In modern code, promises are most often consumed with async functions and await, which make asynchronous code read like ordinary step-by-step code, with errors handled by try...catch. The static methods Promise.all(), Promise.allSettled(), Promise.any() and Promise.race() combine several promises into one.

Creating

new Promise((resolve, reject) => { ... })

Static methods

NameDescription
Promise.all()The Promise.all() static method waits for several promises to finish and gives back all their results in an array.
Promise.allSettled()The Promise.allSettled() static method waits for every promise to finish, whether it succeeds or fails, and reports the outcome of each one.
Promise.any()The Promise.any() static method resolves with the first promise that succeeds, ignoring failures unless every promise fails.
Promise.race()The Promise.race() static method settles as soon as the first of several promises settles, whether it succeeds or fails.
Promise.reject()The Promise.reject() static method returns a promise that is already rejected with a given reason.
Promise.resolve()The Promise.resolve() static method returns a promise that is already fulfilled with a given value.
Promise.withResolvers()The Promise.withResolvers() static method creates a new promise and returns it together with its resolve and reject functions, so it can be settled from outside.

Instance methods

NameDescription
Promise.prototype.catch()The catch() method registers a function to handle a promise's rejection, such as a failed network request.
Promise.prototype.finally()The finally() method runs a function when a promise settles, whether it fulfilled or rejected, which is useful for clean-up such as hiding a loading indicator.
Promise.prototype.then()The then() method registers functions to run when a promise fulfills (or rejects), and returns a new promise so calls can be chained.

Example

function wait(ms, value) {
  return new Promise(resolve => setTimeout(() => resolve(value), ms));
}

wait(500, 'done').then(result => {
  console.log('First promise:', result);
});

async function run() {
  const values = await Promise.all([wait(200, 1), wait(300, 2)]);
  console.log('All settled:', values);
}
run();

Browser Support

The following information will show you the current browser support for the Promise object. Hover over a browser icon to see the version that first introduced support for this object.

This object is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee