PHP output; in javascript?

Which is equivalent to PHP output; in javascript / jQuery?

I need to stop my script at the beginning depending on certain conditions ... The only answers I could find from the search was to stop the forms from submitting ...

+4
source share
3 answers

You can try:

throw "stop execution"; 

Using return, you will skip the current function, so metalization is more like PHP exit ();

+7
source

The javascript function ends with a call to return . Usually you will be in the context of a function or something else. Also, event handlers (for example, for onclick for an element) will behave as a function and accept a return.

+1
source

I would end the function earlier using the return statement:

 return; 
+1
source

Source: https://habr.com/ru/post/1432239/


All Articles