W3cubDocs

/JavaScript

Promise.prototype

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 or onRejected 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

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 32 Yes 29 No 19 8
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 4.4.3 32 Yes 29 Yes 8 Yes
Server
Node.js
Basic support 0.12

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/prototype