Answers for "how to use await to console"

0

how to use await to console

function resolveAfter2Seconds(x) {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve(x);
    }, 2000);
  });
}

async function f1() {
  var x = await resolveAfter2Seconds(10);
  console.log(x); // 10
}

f1();
Posted by: Guest on January-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language