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

Using the Scope Panel to Inspect Variables

Explore local, closure, and global scopes to understand variable availability at each execution point.

Using the Scope Panel to Inspect Variables

You'll learn how to use the debugger's Scope panel to see what variables are accessible at any paused execution point, organized by local, closure, and global scopes.

What the Scope Panel Shows

When you pause code execution with a breakpoint, the Scope panel appears in Chrome DevTools' Sources tab. It displays all variables available at that exact moment, organized into three categories:

  • Local scope: Variables defined in the current function or block
  • Closure scope: Variables from outer functions that the current function has access to
  • Global scope: Variables available everywhere (like window, document, or global variables you've defined)

Why This Matters

Think of scope like different levels of security clearance. The Scope panel shows you exactly what "clearance" your code has at each stopping point. A variable might exist somewhere in your program, but if it's not visible in the Scope panel, your current code can't access it.

Reading the Scope Panel

When paused on a breakpoint:

  1. Local appears at the top—these are the variables you defined in the current function
  2. Closure appears if your function is nested inside another—these are "captured" variables from parent functions
  3. Global lists everything accessible everywhere, including browser APIs and your global variables

You can expand objects and arrays inline to inspect their contents without adding watch expressions. This helps you understand why a variable has (or doesn't have) a certain value.

Key Takeaway: The Scope panel reveals the three-tier hierarchy of variable accessibility (local, closure, global) at your breakpoint, showing exactly what your code can "see" at that execution moment—essential for debugging scope-related issues.