The PromiseRejectionEvent() constructor returns a newly created PromiseRejectionEvent, which represents events fired when a JavaScript Promise is rejected.
Syntax
new PromiseRejectionEvent(type, {
promise: somePromise,
reason : someValue
});
Parameters
The PromiseRejectionEvent() constructor also inherits arguments from Event().
type- A string representing the name of the type of the
PromiseRejectionEvent. This is case-sensitive and must be one of"rejectionhandled"or"unhandledrejection". promise- The
Promisethat was rejected. reason- Any value or
Objectwhich represents the reason the promise was rejected.
Examples
var myRejectionEvent = new PromiseRejectionEvent('unhandledrejection', {
promise : myPromise,
reason : 'My house is on fire'
});
Specifications
| Specification | Status | Comment |
|---|---|---|
| WHATWG HTML Living Standard The definition of 'PromiseRejectionEvent()' in that specification. |
Living Standard | Initial definition. |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 49 | No support[1] | No support | No support | No support |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | No support | No support[1] | No support | No support | No support |
[1] In Firefox, this is implemented but disabled by default. To turn it on, go to about:config and set the dom.promise_rejection_events.enabled pref to true.