“JavaScript Sleep 1 seconde” Réponses codées

JavaScript Sleep 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) {
  return new Promise(resolve => setTimeout(resolve, time));
}

async function test() {
  console.log('start timer');
  await delay(1000);
  console.log('after 1 second');
}

test();
MorbidMeta

JavaScript Sleep 1 seconde

import time
def time_sleep ( sec=1.0 ):
  time.sleep( sec )
  return
Jirayu Kaewprateep

JavaScript Sleep 1 seconde

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

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

# this is just a trial of adding answers with Grepper
Mohieddine Farid

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

// `sleep' function from @Clever Cheetah
function sleep(delay) {
    let start = new Date().getTime();
    while (new Date().getTime() < start + delay);
}

sleep(1000);
console.log("Do something")
Tame Tern

JavaScript Sleep 1 seconde

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

delay(1000).then(() => console.log('ran after 1 second passed'));
Davin Leo

Réponses similaires à “JavaScript Sleep 1 seconde”

Questions similaires à “JavaScript Sleep 1 seconde”

Plus de réponses similaires à “JavaScript Sleep 1 seconde” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code