Why Debugging Skills Matter
Experienced developers aren't the ones who write bug-free code — they're the ones who find and fix bugs quickly. Sharpening your debugging workflow is one of the highest-leverage skills you can develop. Here are 10 techniques to level up immediately.
1. Use console.table() for Arrays and Objects
Instead of printing messy JSON blobs, use console.table() to display arrays of objects in a clean, readable table format right in your DevTools console.
const users = [{ name: 'Alice', age: 28 }, { name: 'Bob', age: 34 }];
console.table(users);
2. Label Your Console Logs
Avoid vague console.log(value) calls. Wrap variables in an object to auto-label them:
console.log({ userId, token, response });
This prints the variable name alongside its value, saving you from confusion when multiple logs fire.
3. Set Breakpoints in DevTools — Not Just debugger
Typing debugger in your code works, but it's easy to forget to remove. Instead, set breakpoints directly in the browser's Sources panel. You can even use conditional breakpoints that only pause execution when a specific condition is true.
4. Use console.trace() to Follow the Call Stack
When a function is called unexpectedly, console.trace() prints the full call stack at that point, showing you exactly how execution arrived there.
5. Watch Expressions in DevTools
In the DevTools "Watch" panel, you can add any JavaScript expression to monitor its value as you step through code. This is far more powerful than adding multiple console.log calls.
6. Isolate the Problem with Binary Search
If a block of code is misbehaving, comment out half of it. Does the bug persist? If no, the bug is in the commented-out half. This "binary search" method drastically reduces the time to locate a bug in large codebases.
7. Check the Network Tab for API Issues
Many frontend bugs are actually backend or network issues. The Network tab in DevTools shows every HTTP request, its status code, headers, request payload, and response body. Always check here before diving into JavaScript logic.
8. Use typeof and Array.isArray() to Catch Type Errors
A huge proportion of bugs come from unexpected data types. When something isn't working, quickly verify what you're actually dealing with:
console.log(typeof myVariable);
console.log(Array.isArray(myList));
9. Reproduce the Bug in Isolation
Create a minimal reproduction — the smallest possible code snippet that still triggers the bug. Tools like CodePen, StackBlitz, or even a plain HTML file are perfect for this. Isolating the problem often reveals the cause immediately.
10. Read the Error Message Carefully
This sounds obvious, but many developers scan error messages rather than reading them. The error type, message, and line number together usually point directly to the problem. Common errors to know:
- TypeError — calling something that isn't a function, or accessing a property of
null/undefined - ReferenceError — using a variable that hasn't been declared
- SyntaxError — malformed code that couldn't be parsed
- RangeError — a value is outside the allowed range (e.g., infinite recursion)
Build a Debugging Habit
Great debugging is a discipline, not just a skill. Before reaching for console.log, ask yourself: What do I expect this value to be, and why? Forming a hypothesis before testing it makes you faster and helps you understand your own code more deeply.