Your product could be here, in front of thousands of JavaScript developers. Sponsor this spot →
JavaScript Quiz

What does an async function return in JavaScript?

Do you know what will be the output of this code?

JavaScript
async function f() {
  return 1;
}

console.log(f() instanceof Promise);
Show answer and explanation

The answer is true.

async functions always return a promise. return 1 becomes Promise.resolve(1), so you need await f() or .then() to get the 1.

Take the full quiz Next question →

More Promises & Async questions

  1. Why does an arrow function in setTimeout keep this?
  2. Why does a Promise run before setTimeout 0?
  3. What runs first after await in JavaScript?
  4. Is the Promise constructor callback synchronous?
  5. What happens when one promise in Promise.all rejects?

Related topics