Home | Mailing List | Blog | Tutorial Videos

Async/Await

Consider the following async function and its output. What will be displayed to the console when calling the f() function?

async function f() {
  let result = 'first!';
  let promise = new Promise((resolve, reject) => {
    setTimeout(() => resolve('done!'), 1000);
  });

  result = await promise;

  console.log(result);
}

f();

Select one: