“JavaScript dors pendant 1 seconde” Réponses codées

JavaScript dors pendant 1 seconde

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

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

JavaScript Sleep 1 seconde

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

test();
Clear Cat

Version javascript du sommeil

//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 Sleep 1 seconde

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

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

attendre javascript

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

JS dors 1 seconde

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

Réponses similaires à “JavaScript dors pendant 1 seconde”

Questions similaires à “JavaScript dors pendant 1 seconde”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code