stop function execution in javascript code example
Example 1: javascript stop execution
// EXAMPLE
throw new Error("This is your custom error message");
/*
SYNTAX
throw new Error("<your-custom-message>");
*/
Example 2: js break out of a function
By using 'return;':
function myfunction(){
if(a == 'stop')
return; //returns Void, ending function
}
Does not work when using a Conditional operator:
let result = 1 == 2 ? "YES" : return; //<--- throws error