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 =;

  var currentDate = null;

  do { currentDate =; } 

  while (currentDate – date < milliseconds);


Leave a Reply

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

Enable Notifications OK No thanks