“JavaScript tidur selama 1 detik” 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

versi tidur javascript

//Javascipt is asyncronous so you can't pause/block code execution
//You can delay doing something with setTimeout
setTimeout(function(){
 	alert("Sup!"); 
}, 2000);//wait 2 seconds
Grepper

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

Tunggu Javascript

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

JS tidur 1 detik

await new Promise(resolve => setTimeout(resolve, milliseconds))
xXjojaXx

Jawaban yang mirip dengan “JavaScript tidur selama 1 detik”

Pertanyaan yang mirip dengan “JavaScript tidur selama 1 detik”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya