是否可能從函數中斷執行程序或者我需要檢查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