1//code before the pause
2setTimeout(function(){
3 //do what you need here
4}, 2000);
5
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);
1setTimeout(function () {
2 // ...
3 }, 10000);
4
5// or
6
7.then(() => {
8 // ...
9 ({ timeout: 10000 });
10 });
1function sleep(ms) {
2 return new Promise(resolve => setTimeout(resolve, ms));
3}