码迷,mamicode.com
首页 > 其他好文 > 详细

for await of异步操作集合遍历

时间:2020-01-23 22:48:55      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:sync   rom   console   UNC   fun   操作   wait   ISE   test   

function Gen (time) {
  return new Promise((resolve,reject) => {
    setTimeout(function () {
       resolve(time)
    },time)
  })
}

async  function test () {
   let arr = [Gen(2000),Gen(100),Gen(3000)]
   for await (let item of arr) {
      console.log(Date.now(),item)
   }
}
test()

 

for await of异步操作集合遍历

标签:sync   rom   console   UNC   fun   操作   wait   ISE   test   

原文地址:https://www.cnblogs.com/qjb2404/p/12231570.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!