diff --git a/source/_posts/异步JavaScript.md b/source/_posts/异步JavaScript.md index c097826..579eabf 100644 --- a/source/_posts/异步JavaScript.md +++ b/source/_posts/异步JavaScript.md @@ -195,4 +195,20 @@ function eat(value) { let orderPizza = new Promise (orderExecutor); orderPizza.then(eat).then(function (value) { console.log(value); }); -``` \ No newline at end of file +``` + +你还可以返回其他promise,这些promise将暂停下一个then回调的执行,知道它被解决 + +```javascript +function eatExecutor(resolve, reject) { + console.log('eating our pizza...'); + setTimeout(resolve, 3000) +} + +function eat() { + return new Promise (eatExecutor); +} + +let orderPizza = new Promise(orderExecutor); +orderPizza.then(eat).then(function () { console.log('Paying the bill!'); }); +```