Knowledgebase

Debugging JavaScript in the Browser Print

  • googletechnology, google, domaintransfer, guide, howto, solution, zillionkinghost, hosting
  • 0

Finding faults in running code.

WHAT THE DEBUGGER PROVIDES

Pausing at a chosen line Inspecting every value in scope Stepping through execution Examining the call stack Watching expressions

WHY IT BEATS LOGGING VALUES

It shows everything without modifying code, and lets you explore.

WHAT TO LEARN

Setting breakpoints, including conditional ones Breaking on exceptions Breaking when an element changes Stepping into, over and out of calls

WHAT CONDITIONAL BREAKPOINTS SOLVE

Pausing only when a condition holds, inside a loop running thousands of times.

WHAT BREAKING ON ELEMENT CHANGES SOLVES

Finding what modified something, when you do not know where.

WHAT SOURCE MAPS PROVIDE

Debugging your original code rather than the minified output.

WHY THAT MATTERS

Minified code is unreadable, and a stack trace against it is useless.

WHAT TO CONFIGURE

Source map generation in your build.

WHAT TO CHECK WHEN A BREAKPOINT DOES NOT HIT

Whether the code actually runs Whether source maps are correct Whether the file is the one being executed

WHAT TO DO WITH ASYNCHRONOUS CODE

Use the asynchronous stack, which shows what initiated the operation.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot