Tag Archives: terminate execution

Javascript – how to stop/terminate execution

When debugging I often find myself printing many values to the screen and ending script execution (in PHP) to verify that I got the right values. Well, since JavaScript loads last and you will get most of your page loaded, you can use the combination of console.log() function and throw statement.

The throw statement will intentionally throw an error or a specified statement, but most of all it will terminate your JavaScript code.

Quick and easy.