nodejs promise sleep
snippet in javascript

nodejs promise sleep

user9130

await new Promise(r => setTimeout(r, 2000));

javascript version of sleep

user5700

//Javascipt is asyncronous so you can't pause/block code execution
//You can delay doing something with setTimeout
setTimeout(function(){
 	alert("Sup!"); 
}, 2000);//wait 2 seconds