“JS SPLEEP” Kod odpowiedzi

Sen JavaScript

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

JS SPLEEP

function sleep(delay) {
    var start = new Date().getTime();
    while (new Date().getTime() < start + delay);
}
Clever Cheetah

Odpowiedzi podobne do “JS SPLEEP”

Pytania podobne do “JS SPLEEP”

Więcej pokrewnych odpowiedzi na “JS SPLEEP” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu