Promise.reject()
method returns a
Promise
object that is rejected with a given reason.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Promise.reject(reason);
reason
Promise
rejected.
A
Promise
that is rejected with the given reason.
静态
Promise.reject
function returns a
Promise
that is rejected. For debugging purposes and selective error catching, it is useful to make
reason
an
instanceof
Error
.
Promise.reject(new Error('fail')).then(function() {
// not called
}, function(error) {
console.error(error); // Stacktrace
});
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'Promise.reject' in that specification. |
To contribute to this compatibility data, please write a pull request against this repository: https://github.com/mdn/browser-compat-data .
更新 GitHub 上的兼容性数据| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
reject()
|
Chrome 32 | Edge 12 | Firefox 29 | IE No | Opera 19 | Safari 8 | WebView Android 4.4.3 | Chrome Android 32 | Firefox Android 29 | Opera Android 19 | Safari iOS 8 | Samsung Internet Android 2.0 | nodejs 0.12 |
完整支持
不支持
Promise
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()