1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

Merge pull request #353 from wshow/patch-1

更新 async
This commit is contained in:
Ruan YiFeng 2017-03-24 20:24:38 +08:00 committed by GitHub
commit d6ed1de83c

View File

@ -376,8 +376,8 @@ async function dbFuc(db) {
上面代码会报错,因为`await`用在普通函数之中了。但是,如果将`forEach`方法的参数改成`async`函数,也有问题。
```javascript
async function dbFuc(db) {
let docs = [{}, {}, {}];
function dbFuc(db) { //这里不需要 async
 let docs = [{}, {}, {}];
// 可能得到错误结果
docs.forEach(async function (doc) {