【发布时间】:2020-11-01 15:35:25
【问题描述】:
const somefunction = async () => {
const arr = [...]
for(let i = 0 ; i < arr.length ; ++i){
await updater(arr[i])
}
}
上面的for循环会等待promise解决后再进行下一次迭代,但是,这现在是nodejs中主事件循环的阻塞动作吗?
请注意:这是一个“for”而不是“forEach”循环。很不一样。
【问题讨论】:
-
这能回答你的问题吗? Using async/await with a forEach loop
-
没有@TobiasSchäfer
-
该问题专门指 forEach,它与 for 循环完全不同