菜鸟一枚,感谢各位:
高程3上说“只要代码中包含 finally 子句,那么无论 try 还是 catch 语句块 中的 return 语句都将被忽略。”但是我做的一个测试出现了这样的结果:
var example = function() {
try {
window.someNonexistentFunction();
} catch (error) {
console.log(error.name);
console.log(error.message);
return 1;
} finally {
console.log('everything is over');
}
};
example();
Firebug中的输出:最后为什么会输出1?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
不管怎样,finally都会执行