Setting Breakpoints
Pause execution and inspect state.
Setting Breakpoints is a free JavaScript Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the JavaScript Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is a Breakpoint
A breakpoint tells the debugger to pause execution at a specific line. While paused, you can inspect variables and the call stack to understand the program state.
Why Breakpoints Beat Logging
Compared with scattering log statements, breakpoints let you examine every variable in scope at a moment without changing the code, and you can continue or step from there.
Opening the Sources Panel
In browser DevTools, breakpoints live in the Sources panel. You open DevTools, switch to Sources, and find your script file in the file tree.
Setting a Line Breakpoint
Click the line number gutter next to a statement to set a breakpoint there. A marker appears, and execution will pause when that line is about to run.
The debugger Statement
Adding a debugger statement in your code triggers a breakpoint programmatically when DevTools is open. It is removed before shipping production code.
function compute(x) {
const doubled = x * 2
// a debugger statement on the next line would pause execution here
return doubled + 1
}Conditional Breakpoints
Right-clicking a line lets you add a condition. The debugger pauses only when the expression is true, which is invaluable inside loops.
Logpoints
A logpoint prints a message without pausing, like a temporary log statement you add through DevTools instead of editing source code.
Inspecting Variables
When paused, the Scope pane lists local, closure, and global variables with their current values, so you can verify your assumptions.
Watch Expressions
The Watch pane evaluates expressions you define on every pause, letting you monitor a computed value as you step through code.
Breakpoints on Events
DevTools can also break on events, such as a click or a network request, pausing execution the moment that event fires.
Managing Breakpoints
The Breakpoints pane lists all your breakpoints. You can disable them temporarily with a checkbox or remove them when finished debugging.
Quick Check
Test your breakpoint knowledge.
Recap
Recap: Breakpoints pause execution for inspection.
- Set them in the Sources panel gutter
- The debugger statement breaks programmatically
- Conditional breakpoints pause only when true
- Inspect scope and watch expressions while paused
Frequently asked questions
Is the “Setting Breakpoints” lesson free?
Yes — the full text of “Setting Breakpoints” is free to read here on the web, and the JavaScript Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the JavaScript Academy course, upgrade to CoddyKit PRO.
What will I learn in “Setting Breakpoints”?
Pause execution and inspect state. You practise JavaScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start JavaScript Academy?
No prior experience is required. JavaScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Setting Breakpoints” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this JavaScript Academy lesson?
Yes. Every JavaScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Beyond console.log
- Setting Breakpoints
- Stepping Through Code
- Reading Stack Traces