For debugging purposes, it is sometimes useful to insert a line of code to easily stop everything from running, and to be able to do this from inside a function or outside all functions.
PHP’s exit() does this. But I’m not aware of any similar method in Javascript. I have read thow''; works, but I wonder if there is a more elegant way of doing it.
In server side code, you can use process.exit(). There is no way to exit the interpreter in the browser; throwing an exception is as close as you can come to that, though it will have no effect on the event loop.