鲤鱼打个滚

关注

JavaScript 利用 async await 实现 sleep 效果

鲤鱼打个滚

关注

阅读 84

2023-04-17

const sleep = (timeountMS) => new Promise((resolve) => {
  setTimeout(resolve, timeountMS);
});
 
(async () => {
  console.log('11111111, ' + new Date());
  await sleep(2000);
  console.log('22222222, ' + new Date());
  await sleep(2000);
  console.log('33333333, ' + new Date());
})();

相关推荐

大明宫

JavaScript async await 使用

大明宫 71 0 0

诗远

【JavaScript】浅谈Async / Await

诗远 92 0 0

mm_tang

JavaScript 引擎是如何实现 async/await 的

mm_tang 85 0 0

幺幺零

JavaScript 的 async/await : async 和 await 在干什么

幺幺零 76 0 0

闲嫌咸贤

【译】JavaScript中的async/await

闲嫌咸贤 141 0 0

曾宝月

async/await

曾宝月 65 0 0

心存浪漫

JavaScript中的async/await的实现原理及手写

心存浪漫 68 0 0

闲云困兽

JavaScript 回调函数/Promise/ async/await

闲云困兽 80 0 0

路西法阁下

async/await实现Promise.acll()

路西法阁下 171 0 0

南柯Taylor

Promise、await、async

南柯Taylor 78 0 0

精彩评论(0)

0 0 举报