1//code before the pause
2setTimeout(function(){
3 //do what you need here
4}, 2000);
5
1//code before the pause
2setTimeout(function(){
3 //do what you need here
4}, 2000);
1function sleep(milliseconds) {
2 const start = Date.now();
3 while (Date.now() - start < milliseconds);
4}
5
6console.log("Hello");
7sleep(2000);
8console.log("World!");
9
1function sleep(ms) {
2 return new Promise(resolve => setTimeout(resolve, ms));
3}
4
5console.log("Hello");
6sleep(2000).then(() => { console.log("World!"); });
7