Shane Jix

[Snippet] - JavaScript Sleep

create:January 10, 2022  update:April 12, 2022  ☕️ 1 min read

同步链接: https://www.shanejix.com/posts/[Snippet] - JavaScript Sleep/

const sleep = (milliseconds) => {
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
};

usage:

await sleep(1000);

作者:shanejix 出处:https://www.shanejix.com/posts/[Snippet] - JavaScript Sleep/ 版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。 声明:转载请注明出处!

Edit on GitHubDiscuss on GitHub


Shane Jix

Personal blog by Shane Jix. I explain with words and code.

LinksTools
© 2019 - 2022, Built withGatsby