js stop function code example
Example 1: stop a function javascript
function func() {
if (conditionToStopFunction)
return; //Nothing after return will be executed
console.log("Hello World"); //This will not be executed if 'conditionToStopFunction' is true
}
Example 2: in javascipt how to stop further page processing
if(someEventHappened) return; // Will prevent subsequent code from being executed
alert("This alert will never be shown.");