“JavaScript Schlaf 1 Sekunde” Code-Antworten

JavaScript Schlaf 1 Sekunde

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

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

JavaScript Schlaf 1 Sekunde

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

test();
Clear Cat

JavaScript Schlaf 1 Sekunde

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 Schlaf 1 Sekunde

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

JavaScript Schlaf 1 Sekunde

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

JavaScript Schlaf 1 Sekunde

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

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

JavaScript Schlaf 1 Sekunde

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

JavaScript Schlaf 1 Sekunde

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 Schlaf 1 Sekunde

// `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 Schlaf 1 Sekunde

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

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

Ähnliche Antworten wie “JavaScript Schlaf 1 Sekunde”

Fragen ähnlich wie “JavaScript Schlaf 1 Sekunde”

Weitere verwandte Antworten zu “JavaScript Schlaf 1 Sekunde” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen