Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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 :: javascript multiline string 
Javascript :: JavaScript - The first word of a string 
Javascript :: convert a string to a number in js 
Javascript :: return the next higher prime number javascript 
Javascript :: js transform 
Javascript :: how to delete node_modules file 
Javascript :: js background 
Javascript :: clear arrays in jquery 
Javascript :: js skip to next iteration 
Javascript :: electron file association 
Javascript :: xmlhttprequest response 
Javascript :: install gulp ubuntu 20.04 
Javascript :: reverse a linked list javascript 
Javascript :: loop through map in js 
Javascript :: list methods of object js 
Javascript :: how to call datetime in javascript 
Javascript :: mui how to set background in theme 
Javascript :: momeny day in range 
Javascript :: popin localstorage once 
Javascript :: get random element from array js 
Javascript :: cheerio get href text 
Javascript :: js date format mm/dd/yyyy 
Javascript :: white screen issue in react native splashscreen 
Javascript :: adding firebase to angular 
Javascript :: javascript replace doublequote with empty string 
Javascript :: js window active 
Javascript :: js transitions 
Javascript :: javascript add hours 
Javascript :: react native new line character 
Javascript :: prop type for ref in react js 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =