是否可能从函数中断执行程序或者我需要检查boolean val返回?从函数中断执行
代码
function check(something) {
if (!something) return;
// Else pass and program continuing
}
check(false); // I want to stop execution because function has returned
// Or I need to check value like if (!check(false)) return; ?
// I want easiest possible without re-check value of function..
alert("hello");
办法阻止从函数执行,而无需重新检查其返回值... – Davide
您只能'return'如果您'在一个函数中。从顶级脚本代码无法做到这一点。 – Barmar
@Barmar [除非你使用Node.js](http://stackoverflow.com/q/28955047/1903116):D – thefourtheye