Js Wait 1 Second

js wait 1 second
function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}

delay(1000).then(() => console.log('ran after 1 second1 passed'));
jquery pause n seconds
setTimeout(
function()
{
//do something special
}, 5000);
javascript wait 1 second
setTimeout(function(){
console.log("Ready")
}, 1000);
javascript wait 1 second
setTimeout(() => {console.log('1 second finished!')}, 1000);
javascript wait 10 seconds
setTimeout(function () {
// ...
}, 10000);

// or

.then(() => {
// ...
({ timeout: 10000 });
});
js wait 5 second
function sleep(num) {
let now = new Date();
const stop = now.getTime() + num;
while(true) {
now = new Date();
if(now.getTime() > stop) return;
}
}

sleep(1000)
console.log('delay 1 second');

 

Leave a Comment