JS does not have PHP’s exit, nor does JAVA’s return.
If the JS code is not a function and you need to abort JS execution, there is only one way, and that is:
document.location.href=your_url;
In addition, although throw can be terminated, it is still an unfriendly error message. Therefore, if you want to terminate it in a friendly manner, you can only use the above method.
Therefore, non-function mode code cannot stay on the current page to implement abort.