mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 10:22:23 +00:00
更新 async
这里不需要 `async` 去掉更容易理解其原理。
This commit is contained in:
parent
ea989e002d
commit
2c4d545dcc
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user