JavaScript/保留字/finally
外观
< JavaScript | 保留字
(重定向自 JavaScript/Reserved Words/finally)Thefinally关键字用作 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