I’m debugging unobfuscated Javascript code. At some point, the code gets stuck in some never-returning function or infinite loop. What’s the fastest way to find this part of the code? I assume there’s a better way than adding a bunch of breakpoins/prints.
I’m using Chrome Developer Tools.
>Solution :
If you open devtools and wait for the code to get to the infinite loop, you can click the pause button in devtools, which will pause the code somewhere within the loop.
For instance, I wrote a page with this code:
setTimeout(() => {
let n = 0;
while (isFinite(n)) {
n = n + 1;
}
}, 800);
and ran it, opened devtools, and clicked the Pause button. It paused the code in the while:

