[WPS JS Tutorial] The sleep() function sleeps or waits, understand in 1 minute! ! !

function sleep(sleepTime) {
    for(var start = new Date; new Date - start <= sleepTime;) {}
}

function main(){
  alert("关注公众号【小知识酷】,搜索“WPS JS”获取更多相关教程")
  sleep(3000)
  alert("已经给你3秒钟了,相信你已经关注了,爱你~")
  alert("再给你5秒钟时间,你可以看看其他的内容");
  sleep(5000);
  alert("酷酷提醒你代码即将结束");
}

code description

  1. We customize a sleepfunction startfor the initial time
  2. new Dateis the latest time - start= the time that has elapsed
  3. When we want to use it, just use sleep()it directly

Guess you like

Origin blog.csdn.net/MrFlySand/article/details/130120694