简体   繁体   中英

Best Practice to Pause in Javascript

What is the best way to pause in JavaScript. I have attempted to use the setTimeout() function before, but I really got confused on how it works.

var pauseTime = 1000; //this is in milliseconds
setTimeout(runThisFunction,pauseTime);

function runThisFunction(){
 alert("i waited a second to run!");
}

it works by waiting x milliseconds then calls the function you pass .. in this case the function name is runThisFunction

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM