“Tunggu Fungsi di JavaScript” Kode Jawaban

tunggu javascript waktu

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

JS Tunggu Waktu

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

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

bagaimana cara menunggu di javascript

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

Tunggu Javascript

 wait(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
 }
Graceful Guanaco

JS tunggu

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

Tunggu Fungsi di JavaScript

console.log("Hello");
setTimeout(() => {  console.log("World!"); }, 2000);
Silly Skylark

Jawaban yang mirip dengan “Tunggu Fungsi di JavaScript”

Pertanyaan yang mirip dengan “Tunggu Fungsi di JavaScript”

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

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya