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
1setTimeout(function () {
2 // ...
3 }, 10000);
4
5// or
6
7.then(() => {
8 // ...
9 ({ timeout: 10000 });
10 });