“Javascript dors une 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

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

JavaScript Sleep 1 seconde

impact int.java
Selfish Scarab

JavaScript Sleep 1 seconde

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 dors une seconde

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

Réponses similaires à “Javascript dors une seconde”

Questions similaires à “Javascript dors une seconde”

Plus de réponses similaires à “Javascript dors une seconde” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code