How to create sleep function for N seconds in JavaScript

1 Answer

0 votes
function sleep(seconds) {
  seconds = (+new Date) + seconds * 1000;
  while ((+new Date) < seconds);
}

 



answered May 29, 2018 by avibootz

Related questions

1 answer 268 views
1 answer 316 views
1 answer 243 views
3 answers 353 views
2 answers 296 views
1 answer 283 views
2 answers 325 views
...