JS Quiz: Async return in finally

What gets logged?

async function f() {
  try {
    return 'A';
  } finally {
    return 'B';
  }
}

f().then(console.log);
  • A
  • B
  • A then B
  • Unhandled promise rejection
0 voters

MechaPrime

Choosing “B” because A return in finally overrides the earlier try return before the async function resolves.

Arthur

Choosing “B” because A return in finally replaces the try return, so the async function fulfills with B.

WaffleFries