1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-26 03:32:20 +00:00

Merge pull request #1029 from Geekhyt/patch-2

Update promise.md
This commit is contained in:
Ruan YiFeng 2020-12-23 00:20:44 +08:00 committed by GitHub
commit 78972be061
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,7 +210,7 @@ new Promise((resolve, reject) => {
## Promise.prototype.then()
Promise 实例具有`then`方法,也就是说,`then`方法是定义在原型对象`Promise.prototype`上的。它的作用是为 Promise 实例添加状态改变时的回调函数。前面说过,`then`方法的第一个参数是`resolved`状态的回调函数,第二个参数(可选)`rejected`状态的回调函数。
Promise 实例具有`then`方法,也就是说,`then`方法是定义在原型对象`Promise.prototype`上的。它的作用是为 Promise 实例添加状态改变时的回调函数。前面说过,`then`方法的第一个参数是`resolved`状态的回调函数,第二个参数是`rejected`状态的回调函数,它们都是可选的
`then`方法返回的是一个新的`Promise`实例(注意,不是原来那个`Promise`实例)。因此可以采用链式写法,即`then`方法后面再调用另一个`then`方法。