You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!
The Promise
.prototype
property represents the prototype for the Promise
constructor
Property attributes of Promise.prototype |
|
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
Description
Promise
instances inherit from Promise.prototype
. You can use the constructor's prototype object to add properties or methods to all Promise
instances.
Properties
Promise.prototype.constructor
- Returns the function that created an instance's prototype. This is the
Promise
function by default.
Methods
Promise.prototype.catch(onRejected)
- 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.
Promise.prototype.then(onFulfilled, onRejected)
- Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler, or to its original settled value if the promise was not handled (i.e. if the relevant handler
onFulfilled
oronRejected
is not a function). Promise.prototype.finally(onFinally)
- Appends a handler to the promise, and returns a new promise which is resolved when the original promise is resolved. The handler is called when the promise is settled, whether fulfilled or rejected.
Specifications
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Promise.prototype' in that specification. |
Standard | Initial definition. |
ECMAScript Latest Draft (ECMA-262) The definition of 'Promise.prototype' in that specification. |
Draft |
Browser compatibility
To contribute to this compatibility data, please write a pull request against this repository: https://github.com/mdn/browser-compat-data.
Update compatibility data on GitHub
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
prototype | Chrome Full support 32 | Edge Full support 12 | Firefox Full support 29 | IE No support No | Opera Full support 19 | Safari Full support 8 | WebView Android Full support 4.4.3 | Chrome Android Full support 32 | Firefox Android Full support 29 | Opera Android Full support Yes | Safari iOS Full support 8 | Samsung Internet Android Full support 2.0 | nodejs Full support 0.12 |
Legend
- Full support
- Full support
- No support
- No support