Hey.
There are situations when, during the execution of a script, the browser hangs along with its devtuls. At the same time, I cannot find out where the error is in the script, since the devtusl is frozen. You have to comment out different pieces of code and catch the place with an error in this way.
For example, at the moment I am debugging a script, the script causes ANY browser to hang. And any browser devtuls doesn't work.
What can be done?
Already thought of the answer. A browser hang causes not infinite recursion (it causes an error — an overflow of the execution context stack, not a browser hang), but an infinite loop. To catch DIRECTLY which of the dozens of cycles in the program looped endlessly, you can use, for example, a recursive function instead of cycles. For example, instead of a loop
for(var i=0;i<5;i=i+1) { console.log(i); }
Write recursive function
var i=0; function cycle(){ console.log(i); i=i+1; if(i==5) return; cycle() }; cycle();