Advanced Debugging: Breakpoints & Watch
Take your debugging skills to the next level. This lesson covers advanced breakpoint types, call stack navigation, memory inspection, and debugging complex asynchronous code.
1Conditional & Logpoint Breakpoints
Right-click any gutter dot to edit a breakpoint. Conditional breakpoints only pause when an expression is true — essential for debugging loops. Logpoints log messages to the console without pausing — non-intrusive production-style debugging in dev.
Condition: user.id === 42 Hit Count: >= 100 Log Message: "Processing order {order.id}"
2Watch Expressions
Add any expression to the Watch panel — it's evaluated live on every pause. Use it to track derived values (items.length, response.status === 200) without cluttering your code with console.logs.
3Inspecting the Call Stack
The Call Stack panel shows every stack frame. Click any frame to navigate to that line and inspect local variables at that point in the execution. This lets you trace how you got to a bug, not just where it is.
4Debugging Async Code
Enable async call stacks in the debug configuration. For Node.js, this shows the chain of await calls that led to the current pause point — critical for debugging promise rejections and async timeouts.
5Memory & Heap Snapshots
For Node.js debugging, VS Code supports heap snapshots via the --inspect flag. Use the JavaScript Debugger heap profiler to detect memory leaks by comparing snapshots before and after an operation.