Back to results for “Error Handling”
JavaScript › Debugging, Testing & Tooling

How do you pause code execution at a specific line using the browser DevTools?

Beginner

Answer

Insert a debugger statement in your code, or click in the gutter of the Sources panel to set a breakpoint. When execution reaches that line, DevTools pauses so you can inspect variables and step through code.
function calculateTotal(items) {
  debugger; // execution pauses here when DevTools is open
  return items.reduce((sum, i) => sum + i.price, 0);
}
Real-world example Pausing mid-function to inspect why a total is calculating incorrectly.

Common follow-ups: What's the difference between 'Step Over', 'Step Into', and 'Step Out'?