MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

这篇翻译不完整。请帮忙从英语翻译这篇文章

该新特性属于 ECMAScript 2015(ES6)规范,在使用时请注意浏览器兼容性。

总结

Promise.prototype 属性表示 Promise 构造器的原型.

Promise.prototype 属性的属性特性:
writable false
enumerable false
configurable false

描述

Promise 实例继承自 Promise.prototype. 你可以用构造器的原型对象来添加属性或方法到所有 Promise 实例上.

属性

Promise.prototype.constructor
返回创建了实例原型的函数.  默认为 Promise 函数.

方法

Promise.prototype.catch(onRejected)
添加一个否定(rejection) 回调到当前 promise, 返回一个新的promise。如果这个回调被调用,新 promise 将以它的返回值来resolve,否则如果当前promise 进入fulfilled状态,则以当前promise的肯定结果作为新promise的肯定结果.
Promise.prototype.then(onFulfilled, onRejected)
添加肯定和否定回调到当前 promise, 返回一个新的 promise, 将以回调的返回值 来resolve.

规范

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
Promise.prototype
Standard Initial definition.

浏览器兼容

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 32 24.0 (24.0) as Future
25.0 (25.0) as Promise behind a flag[1]
29.0 (29.0) by default
未实现 19 7.1
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support 未实现 24.0 (24.0) as Future
25.0 (25.0) as Promise behind a flag[1]
29.0 (29.0) by default
未实现 未实现 iOS 8 32

[1] Gecko 24 has an experimental implementation of Promise, under the initial name of Future. It got renamed to its final name in Gecko 25, but disabled by default behind the flag dom.promise.enabled. Bug 918806 enabled Promises by default in Gecko 29.

另见

文档标签和贡献者

 此页面的贡献者: HenryYong, mountainmoon
 最后编辑者: HenryYong,