1//code before the pause
2setTimeout(function(){
3 //do what you need here
4}, 2000);
5
1var delayInMilliseconds = 1000; //1 second
2
3setTimeout(function() {
4 //your code to be executed after 1 second
5}, delayInMilliseconds);
6
1function sleep(milliseconds) {
2 const date = Date.now();
3 let currentDate = null;
4 do {
5 currentDate = Date.now();
6 } while (currentDate - date < milliseconds);
7}
8
9console.log("Hello");
10sleep(2000);
11console.log("World!");
1//code before the pause
2setTimeout(function(){
3 //do what you need here
4}, 2000);
1var waitTill = new Date(new Date().getTime() + seconds * 1000);
2while(waitTill > new Date()){}