Quantcast
Channel: What is the JavaScript version of sleep()? - Stack Overflow
Viewing all articles
Browse latest Browse all 96

What is the JavaScript version of sleep()?

$
0
0

Is there a better way to engineer a sleep in JavaScript than the following pausecomp function (taken from here)?

function pausecomp(millis){    var date = new Date();    var curDate = null;    do { curDate = new Date(); }    while(curDate-date < millis);}

This is not a duplicate of Sleep in JavaScript - delay between actions; I want a real sleep in the middle of a function, and not a delay before a piece of code executes.


Viewing all articles
Browse latest Browse all 96

Latest Images

Trending Articles



Latest Images