Skip to content

Commit 291f0e6

Browse files
authored
Merge pull request ruanyf#892 from wang1433256766/patch-1
Update promise.md
2 parents 4bb8b17 + 8b126e5 commit 291f0e6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/promise.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ getJSON("/posts.json").then(function(json) {
229229
```javascript
230230
getJSON("/post/1.json").then(function(post) {
231231
return getJSON(post.commentURL);
232-
}).then(function funcA(comments) {
232+
}).then(function (comments) {
233233
console.log("resolved: ", comments);
234-
}, function funcB(err){
234+
}, function (err){
235235
console.log("rejected: ", err);
236236
});
237237
```
238238

239-
上面代码中,第一个`then`方法指定的回调函数,返回的是另一个`Promise`对象。这时,第二个`then`方法指定的回调函数,就会等待这个新的`Promise`对象状态发生变化。如果变为`resolved`就调用`funcA`,如果状态变为`rejected`就调用`funcB`
239+
上面代码中,第一个`then`方法指定的回调函数,返回的是另一个`Promise`对象。这时,第二个`then`方法指定的回调函数,就会等待这个新的`Promise`对象状态发生变化。如果变为`resolved`就调用第一个回调函数,如果状态变为`rejected`就调用第二个回调函数
240240

241241
如果采用箭头函数,上面的代码可以写得更简洁。
242242

0 commit comments

Comments
 (0)