“Js warte” Code-Antworten

JavaScript wartete 1 Sekunde

  setTimeout(function(){ 
    console.log("Ready")
}, 1000);
Foreverekk

JavaScript -Schlaf

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

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

Warten Sie auf Zeit JavaScript

//code before the pause
setTimeout(function(){
    //do what you need here
}, 2000);
PutterBeanut

Js warte auf die Zeit

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

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

wie man in JS wartet

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')
Depressed Dunlin

Js warte

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
}
Ultratiger

Ähnliche Antworten wie “Js warte”

Fragen ähnlich wie “Js warte”

Weitere verwandte Antworten zu “Js warte” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen