JavaScript Promise then()
- Previous page resolve()
- Next page all()
- Go Back to the Previous Level JavaScript Promise Reference Manual
Definition and usage
then()
The method provides two callback functions:
One is executed when the Promise is successful, and one is executed when the Promise is rejected.
Example
myPromise.then(x => myDisplay(x), x => myDisplay(x));
Syntax
promise.then(fulfilled(), rejected())
Parameters
Parameters | Description |
---|---|
fulfilled() | Function to be executed when the Promise is successful. |
rejected() | Function to be executed when the Promise is rejected. |
Return value
Type | Description |
---|---|
Object | New Promise object. |
Browser support
then()
Is a feature of ECMAScript 6 (ES6).
Since June 2017, ES6 (JavaScript 2015) is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
May 2016 | April 2017 | June 2017 | September 2016 | June 2016 |
then()
Not supported by Internet Explorer.
- Previous page resolve()
- Next page all()
- Go Back to the Previous Level JavaScript Promise Reference Manual