console.log("我执行了"); sleep(3000); console.log("我3000ms后执行了");
function sleep(numberMillis) { var now = new Date(); var exitTime = now.getTime() + numberMillis; while (true) { now = new Date(); if (now.getTime() > exitTime) return; } }
console.log("我执行了"); sleep(3000); console.log("我3000ms后执行了");
function sleep(numberMillis) { var now = new Date(); var exitTime = now.getTime() + numberMillis; while (true) { now = new Date(); if (now.getTime() > exitTime) return; } }