There is no real "breaker" for running Javascript code in a browser. ECMAscript is executed in the so-called "user interface thread", which means that all visualization tools occur in the same queue in which the ECMAscript code is executed.
This, in turn, means that the endless loop in ECMAscript automatically freezes in the interaction of all browsers.
The only way to avoid this is to write clean, clean code. If this is the case, most browsers realize that the user interface thread is too busy and asks the user if he wants to cancel running javascript processes. If you do not want to wait for this, your only choice is to kill the entire browser / tab process.
However, if you know that some part of your script can cause an endless loop, you can either install breakpoints manually in some developer tools or insert the debugger; keyword debugger; straight to your script. This causes the javascript interpreter to pause in the current line, and you have the option to parse the following code (while the conditions for the example) and cancel execution if it looks bad.
jAndy
source share