1var delayInMilliseconds = 1000; //1 second
2
3setTimeout(function() {
4 //your code to be executed after 1 second
5}, delayInMilliseconds);
6
1 async function delay(delayInms) {
2 return new Promise(resolve => {
3 setTimeout(() => {
4 resolve(2);
5 }, delayInms);
6 });
7 }
8 async function sample() {
9 console.log('a');
10 console.log('waiting...')
11 let delayres = await delay(3000);
12 console.log('b');
13 }
14 sample();