JavaScript/保留字/finally
外观
< JavaScript | 保留字
该finally关键字用作 try 语句的子句。
代码
var result;
try {
result = log(-12.05);
alert("Executed comment successfully.");
} catch(err) {
document.getElementById("demo").innerHTML = err.message;
} finally {
alert("result = " + result); // This line will execute anyway
}
(将把错误消息添加到名为“demo”的 HTML 元素中。)
result = undefined