Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

wait n seconds in js

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function demo() {
  console.log('Taking a break for 2 seconds...');
  await sleep(2000);
  console.log('2 seconds later');
}

demo();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wait #seconds #js
ADD COMMENT
Topic
Name
6+8 =