JavaScript wait function or sleep function

Problem: If Need a javascript function to wait for a certain time until the next command execution 

Solution:(JavaScript function)

 function sleep(milliseconds) {

  var date = Date.now();

  var currentDate = null;

  do { currentDate = Date.now(); } 

  while (currentDate – date < milliseconds);

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Enable Notifications OK No thanks