DevilRoshan / Question

前端问题解决
0 stars 0 forks source link

[Daily]map和for中调用异步函数的区别,即 #150

Closed DevilRoshan closed 4 years ago

DevilRoshan commented 4 years ago

出自小程序前端面试星球

mapfor中调用异步函数的区别,即

// map
[1, 2, 3].map(async v => {
  // do something
  await asyncFunc(v)
  // do something
})
// for
for(let i = 0; i < 3; i++){
    // do something
  await asyncFunc(i)
  // do something
}
DevilRoshan commented 4 years ago

https://github.com/DevilRoshan/Question/blob/master/20200914-js-promise.md