Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
Technique to detect where Javascript gets stuck?

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.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

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.

enter image description here

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:

enter image description here

about 4 years ago · Juan Pablo Isaza Report

0

If you are really on a loop with the console opened, go to "Sources" tab, then click on the "Pause" icon. The code will pause and you will see where it is stuck :)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!