Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript sleep

function sleep(milliseconds) {
  const date = Date.now();
  let currentDate = null;
  do {
    currentDate = Date.now();
  } while (currentDate - date < milliseconds);
}

console.log("Hello");
sleep(2000);
console.log("World!");
Source by masteringjs.io #
 
PREVIOUS NEXT
Tagged: #javascript #sleep
ADD COMMENT
Topic
Name
4+4 =