Promise - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

Promise.allSettled()

Fulfills when all of the promises fulfill; rejects when any of the promises rejects.

Promise concurrency

The Promise class offers four main static methods to facilitate async task concurrency:

Promise concurrency

The Promise class offers four main static methods to facilitate async task concurrency:

Promise concurrency

The Promise class offers four main static methods to facilitate async task concurrency:

Promise.allKeyed()

The Promise class offers four main static methods to facilitate async task concurrency:

Promise.allSettledKeyed()

The Promise class offers four main static methods to facilitate async task concurrency:

Promise concurrency

The Promise class offers four main static methods to facilitate async task concurrency:

Promise concurrency

The Promise class offers four main static methods to facilitate async task concurrency:

Promise concurrency

The Promise class offers four main static methods to facilitate async task concurrency:

Promise concurrency

The Promise class offers four main static methods to facilitate async task concurrency:

Promise[Symbol.species]

Returns the constructor used to construct return values from promise methods.

Promise.withResolvers()

Takes an iterable of promises as input and returns a single Promise. This returned promise fulfills when all of the input's promises fulfill (including when an empty iterable is passed), with an array of the fulfillment

Promise.prototype.constructor

The constructor function that created the instance object. For Promise instances, the initial value is the Promise constructor.

[Symbol.toStringTag]

The initial value of the [Symbol.toStringTag] property is the string "Promise". This property is used in Object.prototype.toString().

Object.prototype.toString()

The initial value of the [Symbol.toStringTag] property is the string "Promise". This property is used in Object.prototype.toString().

Promise.prototype.catch()

Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.

▶ Advanced Example sample