“Tunggu di JS” Kode Jawaban

Tidur 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

tunggu javascript waktu

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

Bagaimana cara menunggu di 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')
Depressed Dunlin

JavaScript Set Delay

var delayInMilliseconds = 1000; //1 second

setTimeout(function() {
  //your code to be executed after 1 second
}, delayInMilliseconds);
Mobile Star

bagaimana cara menunggu di javascript

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}
Foolish Frog

Tunggu di JS

var waitTill = new Date(new Date().getTime() + seconds * 1000);
while(waitTill > new Date()){}
Colorful Capybara

Jawaban yang mirip dengan “Tunggu di JS”

Pertanyaan yang mirip dengan “Tunggu di JS”

Lebih banyak jawaban terkait untuk “Tunggu di JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya