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 272 views
1 answer 317 views
1 answer 245 views
3 answers 357 views
2 answers 299 views
1 answer 287 views
2 answers 331 views
...