Javascript sleep

Posted by fmsf on Stack Overflow See other posts from Stack Overflow or by fmsf
Published on 2009-06-04T14:41:10Z Indexed on 2010/04/12 6:53 UTC
Read the original article Hit count: 434

Filed under:
|

Is any better way than this function to make a sleep in javascript, or should I just use that 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 dupe of http://stackoverflow.com/questions/758688/sleep-in-javascript I want a real sleep in a middle of a function, not a delay for a piece of code;

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about sleep