Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda