Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

wait for time javascript

//code before the pause
setTimeout(function(){
    //do what you need here
}, 2000);
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 :: Min Stack Algorithm JS 
Javascript :: npm adm-zip 
Javascript :: javascript compare arrays 
Javascript :: 12 hours to 24 hours javascript 
Javascript :: jquery click not working on dynamic content 
Javascript :: add id attribute to jQuery steps 
Javascript :: change span value javascript 
Javascript :: html table to excel javascript 
Javascript :: get cookie in javascript 
Javascript :: javascript function loop through array 
Javascript :: add a Google Font to a VueJS 
Javascript :: Animated: `useNativeDriver` was not specified. This is a required option and must be explicitly set to `true` or `false` 
Javascript :: jspdf save in server 
Javascript :: javascript get element by id 
Javascript :: Count of positives / sum of negatives 
Javascript :: number object js 
Javascript :: js select div 
Javascript :: js print array without comma 
Javascript :: past value from parent in reactjs 
Javascript :: javascript code 
Javascript :: ignore eslint warning one line 
Javascript :: javascript log html element as dom object 
Javascript :: import modules js html 
Javascript :: react text input onchange 
Javascript :: javascript if browser out of focus 
Javascript :: math ceil 
Javascript :: javascript create array with null values 
Javascript :: javascript change color of text input 
Javascript :: Odd number function in javascript 
Javascript :: js replace multiple 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =