I have a JavaScript application on my site such as; if(CONDITION){ [COLOR="Red"]CONCLUDE SCRIPT[/COLOR] } else if{ EXECUTE THIS } [COLOR="RoyalBlue"]MORE CODE HERE[/COLOR] Code (markup): I want to make the script finish if the CONDITION is true. So no code will be executed after the CONCLUDE SCRIPT such as the MORE CODE HERE. Is there such an option in JavaScript?
nest it within a function and then use return; to exit the function: <script type="text/javascript" > new function main(){ var a = 1; if(a==1) return; else alert(a); //execute more code alert(a + 8 - 2); } </script> Code (markup): Using 'new function main() {' will call the function when it is created.