📜  js 等待 - Javascript 代码示例

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

代码示例6
function wait(milliseconds) {
  const date = Date.now();
  let currentDate = null;
  do {
    currentDate = Date.now();
  } while (currentDate - date < milliseconds);
}

function your_code() {
  //code stuff
  wait(1000); //waits 1 second before continuing
  //other code stuff
}