Skip to content

主线程死循环指定时间的 js 代码

js
function delay(duration) {
  const start = Date.now()
  while (Date.now() - start < duration) {}
}