“JavaScript tidur sejenak” Kode Jawaban

JavaScript tidur selama 1 detik

function delay(time) {
  return new Promise(resolve => setTimeout(resolve, time));
}

delay(1000).then(() => console.log('ran after 1 second1 passed'));
Powerful Puma

JavaScript tidur 1 detik

async function test() {
  console.log('start timer');
  await new Promise(resolve => setTimeout(resolve, 1000));
  console.log('after 1 second');
}

test();
Clear Cat

JavaScript tidur 1 detik

function delay(time) => new Promise(resolve => setTimeout(resolve, time));

delay(1000).then(() => console.log('ran after 1 second1 passed'));
Long Lyrebird

JavaScript tidur 1 detik

impact int.java
Selfish Scarab

JavaScript tidur 1 detik

setTimeout(myFunction, 3000);

// if you have defined a function named myFunction 
// it will run after 3 seconds (3000 milliseconds)
function test1()
{    
    // let's say JavaScript did have a sleep function..
    // sleep for 3 seconds
    sleep(3000);

    alert('hi'); 
}
Kalyani Sree Selvaganesan

JavaScript tidur sejenak

for (var j = 0; j < 50; j++) {
  setTimeout(function() {
     $('body').append('<iframe src="http://www.example.com"></iframe>');
  }, j * 1000);  // each call is scheduled to run after j seconds
}
Bored Badger

Jawaban yang mirip dengan “JavaScript tidur sejenak”

Pertanyaan yang mirip dengan “JavaScript tidur sejenak”

Lebih banyak jawaban terkait untuk “JavaScript tidur sejenak” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya