📜  settimeout javascript for 循环 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:51.227000             🧑  作者: Mango

代码示例3
//you can leave the sleep constant
const sleep = (milliseconds) => {
  return new Promise(resolve => setTimeout(resolve, milliseconds))
}

const doSomething = async () => {
  for (/*for loop statements here*/) {
  //code before sleep goes here, just change the time below in milliseconds
   await sleep(1000)
  //code after sleep goes here 
    }
  }
doSomething();