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
BobaMilk ![]()
What gets logged?
async function f() {
try {
return 'A';
} finally {
return 'B';
}
}
f().then(console.log);
BobaMilk ![]()
Pick B — return "B" inside finally overrides the return "A" from try, so the promise resolves to "B" and console.log prints B.
Yoshiii
Pick B — the return "B" in finally wins over the return "A" in try, so the async function resolves to "B" and console.log prints B.
WaffleFries
:: Copyright KIRUPA 2024 //--