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 promise all 
Javascript :: hide a div in jquery 
Javascript :: javascript execute powershell script 
Javascript :: js get selected option elemeng 
Javascript :: reset select option jquery 
Javascript :: react render component after data loaded 
Javascript :: normalize in javascript 
Javascript :: difference between library and framework in javascript 
Javascript :: js then 
Javascript :: network display react native 
Javascript :: form submit event get button 
Javascript :: simple alert program in javascript 
Javascript :: sanitizer content nodejs 
Javascript :: javascript Sum of a sequence 
Javascript :: javascript time 
Javascript :: vuejs get value of checkbox group 
Javascript :: javascript explode space 
Javascript :: js check if undefined 
Javascript :: how to get the inner width of a parent div for canvas 
Javascript :: node js currency format 
Javascript :: js datetime format 
Javascript :: types of loops in javascript 
Javascript :: mongo mongoose join aggregation lookup 
Javascript :: swap two variables javascript 
Javascript :: nested array filter 
Javascript :: javascript string replace all 
Javascript :: clear element children js 
Javascript :: disable button based on condition angular 
Javascript :: jquery replace text in div 
Javascript :: java parse json 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =