Back to questions
JuniorTheoryCommon
What does the program print (lines separated by spaces)?
function f() {
try {
return "try";
} finally {
console.log("finally");
}
}
console.log(f());finally try
- Expecting
tryalone:returndoes not skipfinally; thefinallyblock runs before the function actually hands back its value. - Expecting
try finally:finallyruns insidef(), before the caller gets"try", sofinallyis printed first.
- What does
f()return if thefinallyblock also hasreturn "finally";? - Does
finallyrun when thetryblock throws and there is nocatch?