What is the output of the following? “`js async function foo() { return 1; } async function bar() { return await foo(); } bar().then(console.log); “`

JavaScript Developer Hard

JavaScript Developer — Hard

What is the output of the following? “`js async function foo() { return 1; } async function bar() { return await foo(); } bar().then(console.log); “`

Key points

  • The `await` keyword pauses the execution of the `bar` function until the `foo` function resolves.
  • The `then` method is used to handle the resolved value of the promise.
  • The `bar` function returns the resolved value of the `foo` function.

Ready to go further?

Related questions