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 182 views
1 answer 238 views
1 answer 164 views
2 answers 174 views
3 answers 227 views
1 answer 188 views
2 answers 208 views
...