“JavaScript Sleep 1 sekunda” Kod odpowiedzi

JavaScript Sleep 1 sekunda

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 sekunda

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 sekunda

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 sekunda

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

JavaScript Sleep 1 sekunda

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

JavaScript Sleep 1 sekunda

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

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

JavaScript Sleep 1 sekunda

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

JavaScript Sleep 1 sekunda

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 sekunda

// `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 sekunda

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

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

Odpowiedzi podobne do “JavaScript Sleep 1 sekunda”

Pytania podobne do “JavaScript Sleep 1 sekunda”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu