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 :: how to autoclose paranthesis in javascript input 
Javascript :: internacionalizacion ionic 
Javascript :: get random hsl value, javascript 
Javascript :: delete duplicate json object from json object javascript 
Javascript :: chart js bars too light 
Javascript :: database number counter animation javascript from database 
Javascript :: paging react mongoose 
Javascript :: how to unable input text in JS 
Javascript :: 1.047222170078745 
Javascript :: dateFormat 
Javascript :: use node-session with serverless functions 
Javascript :: different getters js 
Javascript :: get all youtube playlist videos as json without api python 
Javascript :: get and storing json array android 
Javascript :: Load Balance 4 instances of api.js node js 
Javascript :: expo draw over other apps 
Javascript :: open menu 
Javascript :: dispatch on unmount 
Javascript :: 1update normalize-url 
Javascript :: how to show stop loading page for some second in nuxt 
Javascript :: facebook graph X-Hub-Signature 
Javascript :: when i send req upload image in node give Error: ENOENT: no such file or directory,ues multer 
Javascript :: react default value for props not showing up 
Javascript :: which is faster python or node.js for image saving as server 
Javascript :: how to bound a state variable to a field react final form 
Javascript :: preview.cookie-consent.js 
Javascript :: session cookie vs persistent cookie 
Javascript :: how to make password star star on input html 
Javascript :: node.js workflow template 
Javascript :: react first click not working 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =