Skip to content
Advertisement

JavaScript equivalent of PHP’s die

Is there something like “die” in JavaScript? I’ve tried with “break”, but doesn’t work 🙂

Advertisement

Answer

You can only break a block scope if you label it. For example:

JavaScript

You cannot break a block scope from within a function in the scope. This means you can’t do stuff like:

JavaScript

You can do something similar though with functions:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement