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 168 views
1 answer 224 views
1 answer 151 views
2 answers 161 views
3 answers 208 views
1 answer 173 views
2 answers 167 views
...