Course contentsShow
← Web Development
Lesson 2254 of 2,98241. Debugging TechniquesFree lesson

Setting Line-of-Code Breakpoints

Master the most common breakpoint type by clicking line numbers in the Sources panel to pause at specific lines.

Setting Line-of-Code Breakpoints

What you'll learn: How to pause JavaScript execution at any specific line by clicking line numbers in the Sources panel.

Now that you understand why breakpoints are essential debugging tools, let's master the most fundamental type: line-of-code breakpoints. These let you freeze your program mid-execution at exactly the line you want to inspect.

How It Works

In Chrome DevTools' Sources panel, navigate to the JavaScript file you want to debug. You'll see line numbers along the left margin. Simply click on any line number where you want execution to pause. A blue marker appears, indicating an active breakpoint.

When your code runs and reaches that line, execution stops before that line executes. The browser freezes, giving you a chance to inspect variables, check the call stack, and understand exactly what's happening at that moment in time.

Think of it like pressing pause on a video at the exact frame you need to examine—except you're pausing your program's execution instead.

Setting Your First Breakpoint

  1. Open DevTools (F12 or right-click → Inspect)
  2. Navigate to the Sources tab
  3. Open the .js file containing your code
  4. Click the line number where you want to pause (the line will highlight with a blue marker)
  5. Trigger the code path (refresh page, click a button, etc.)
  6. Execution pauses, and you can inspect everything

To remove a breakpoint, simply click the blue marker again.

When to Use Line-of-Code Breakpoints

Use them when you know exactly where you suspect a problem exists or want to understand how a particular section of code behaves. They're perfect for investigating why a variable has an unexpected value or why a condition evaluates differently than expected.

Key Takeaway: Line-of-code breakpoints are set by clicking line numbers in the Sources panel and pause execution at that exact line, giving you a frozen snapshot of your program's state to inspect.