Ruan Yifeng"s introduction to ES6-async function
there are two paragraphs:
function dbFuc(db) { // async
let docs = [{}, {}, {}];
//
docs.forEach(async function (doc) {
await db.post(doc);
});
}
//db.postfor
async function dbFuc(db) {
let docs = [{}, {}, {}];
for (let doc of docs) {
await db.post(doc);
}
}
ask why the three db.post operations of forEach
will be executed concurrently , while the for loop
will not? Thank you ~