delay in js
snippet in javascript

javascript HOW set delay

user1948

var delayInMilliseconds = 1000; //1 second

setTimeout(function() {
  //your code to be executed after 1 second
}, delayInMilliseconds);

delay in js

user6738

var delayInMilliseconds = 1000; //1 second

setTimeout(function() {
  //your code to be executed after 1 second
}, delayInMilliseconds);

wait javascript

user3718

 wait(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
 }

js add delay

user1483

await new Promise(resolve => setTimeout(resolve, 1000));

javascipt delay

user9362

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

console.log("Hello");
sleep(2000).then(() => { console.log("World!"); });

javascript wait 5 seconds

user4851

timeout(ms) { //pass a time in milliseconds to this function
    return new Promise(resolve => setTimeout(resolve, ms));
  }