Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sleeping in js

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

//using sleep()
sleep(2000); //sleep for 2 seconds
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sleeping #js
ADD COMMENT
Topic
Name
4+5 =