JavaScript berhenti eksekusi
return false; // or return;
// or
throw new Error("Here we stop");
// Node.js:
process.exit();
VasteMonde
return false; // or return;
// or
throw new Error("Here we stop");
// Node.js:
process.exit();
// EXAMPLE
throw new Error("This is your custom error message");
/*
SYNTAX
throw new Error("<your-custom-message>");
*/
if(someEventHappened) return; // Will prevent subsequent code from being executed
alert("This alert will never be shown.");
// You can make a JavaScript typo :D (thinking outside the box here)
thisFunctionDoesNotExistAndWasCreatedWithTheOnlyPurposeOfStopJavascriptExecutionOfAllTypesIncludingCatchAndAnyArbitraryWeirdScenario();
// Or something like
new new