finally of "try...(catch)...finally"
finally中有回傳值時,會覆蓋(overwrite)先前的回傳值。
e.g.
function run() {
try {
return "abc";
} finally {
return "xyz";
}
}
console.log(run()); // "xyz"
e.g.
function run() {
try {
return "abc";
} finally {
return "xyz";
}
}
console.log(run()); // "xyz"
留言
張貼留言