Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js wait for time

function sleep(milliseconds) {
  const start = Date.now();
  while (Date.now() - start < milliseconds);
}

console.log("Hello");
sleep(2000);
console.log("World!");
Comment

how to wait in js

function wait(sec) {
  const date = Date.now();
  let currentDate = null;
  do {
    currentDate = Date.now();
  } while (currentDate - date < sec*1000);
}

console.log('waiting')

wait(1)

console.log('i am done')
Comment

how to wait in javascript

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

wait javascript

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

js wait

function wait(milliseconds) {
  const date = Date.now();
  let currentDate = null;
  do {
    currentDate = Date.now();
  } while (currentDate - date < milliseconds);
}

function your_code() {
  //code stuff
  wait(1000); //waits 1 second before continuing
  //other code stuff
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: block enter key using jquery 
Javascript :: http get request in javascript 
Javascript :: how to get nth fibonacci javascript 
Javascript :: js get string byte size 
Javascript :: square every digit javascript 
Javascript :: jquery set title 
Javascript :: linebreak-style 
Javascript :: get cuurent route name nextjs 
Javascript :: round up javascript 
Javascript :: bq show pretty json 
Javascript :: remove a particular element from array 
Javascript :: jquery get current row value 
Javascript :: breaking from a labeled while loop js 
Javascript :: vs code prevent auto grml closing in js files 
Javascript :: sort and split js alefbethic 
Javascript :: jspdf addimage auto height 
Javascript :: last element array 
Javascript :: unistall react node package 
Javascript :: javscript .split().reverse.join 
Javascript :: regular expression should not contain special character 
Javascript :: Javascript noFill 
Javascript :: useMutation on success function not being called 
Javascript :: create element javascript with class 
Javascript :: jquery cdn google 
Javascript :: regex match number javascript 
Javascript :: js map over object 
Javascript :: creating a custom router class in backbone 
Javascript :: tooltip.js cdn 
Javascript :: how to move a channel to a category discord js 
Javascript :: js get meta content 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =