Coding 101

Debugging Techniques for Beginners: From Console Logs to DevTools Breakpoints

DD
Ankur Ishwar
7 min read Updated Sep 7, 2026
Debugging techniques for beginner software engineers

During my first months writing JavaScript, my entire debugging toolkit consisted of console.log('here 1'), console.log('here 2'), and console.log('asdf').

One evening, an asynchronous data fetching bug had me trapped for four hours. My terminal was an unreadable stream of eighty printed numbers and objects. A senior engineer sat down next to me, typed debugger; right inside my handler function, opened Chrome DevTools, and pinned the exact null pointer error in ninety seconds.

Debugging is not a mystical sixth sense. It is an engineering discipline. Here is how to graduate from messy console logging to professional browser and Node.js diagnostic tools.

1. Beyond console.log: High-Signal Console APIs

While console.log() is fine for a five-second sanity check, modern runtimes provide far more powerful diagnostic methods that preserve data structure:

const users = [
  { id: 101, name: 'Alex', role: 'admin', active: true },
  { id: 102, name: 'Ankur', role: 'engineer', active: false },
  { id: 103, name: 'Sara', role: 'designer', active: true }
];

// 1. console.table renders objects and arrays into structured, sortable grids
console.table(users, ['name', 'role', 'active']);

// 2. console.time benchmarks operational latency with sub-millisecond precision
console.time('heavyCalculation');
for (let i = 0; i < 1000000; i++) { Math.sqrt(i); }
console.timeEnd('heavyCalculation'); // Prints: heavyCalculation: 3.42ms

// 3. console.assert logs an error ONLY when a condition evaluates to false
const expectedCount = 5;
console.assert(users.length === expectedCount, `Expected ${expectedCount} users but found ${users.length}`);

2. The "debugger" Statement and DevTools Breakpoints

Scattering dozens of print statements pollutes your git history and risks leaking private user data in production bundles. The native debugger; statement tells the JavaScript engine to freeze execution and hand control directly to your browser's DevTools Sources tab:

// Example: finding an edge-case calculation failure
function calculateAverageOrder(orders) {
  let total = 0;
  
  // When DevTools is open, execution pauses here automatically
  debugger;

  for (let i = 0; i < orders.length; i++) {
    total += orders[i].amount;
  }

  // Bug: Division by zero occurs when orders array is empty
  return total / orders.length;
}

When paused, you can hover your cursor over any variable to view its live memory state, evaluate expressions directly in the console, and inspect closure scopes.

3. Mastering DevTools Stepping Controls

When your breakpoint hits, four keyboard shortcuts control your investigation:

  • Resume script execution (F8): Unfreezes execution until the next breakpoint or completion.
  • Step over (F10): Executes the current line of code and pauses on the next line without diving into the internal mechanics of called functions.
  • Step into (F11): Steps directly inside the function called on that line so you can observe parameter assignment.
  • Step out (Shift + F11): Runs the remainder of the current function and pauses immediately in the calling parent scope.

4. Conditional Breakpoints for High-Frequency Loops

If you have an array with 10,000 items and your function crashes only when processing item index 7,421, pressing F10 thousands of times is ridiculous.

Right-click the line number in the DevTools Sources panel and choose Add conditional breakpoint... Enter an expression such as:

item.status === 'corrupted' || item.price < 0

The debugger skips every valid record at full execution speed and only pauses when your condition evaluates to true.

5. Node.js Backend Debugging with Chrome DevTools

You do not need browser HTML to use DevTools. You can inspect any Node.js backend service with Chrome's native V8 inspector:

# Start your Node.js application in inspect mode
node --inspect server.js

# Or break on the very first line before running
node --inspect-brk server.js

Now open Chrome and open chrome://inspect. Click Configure..., ensure localhost:9229 is listed, and click Open dedicated DevTools for Node. You get the full graphical debugging experience for your backend APIs.

6. How to Read a Minified Stack Trace

When an unhandled exception crashes your code, novice developers get frightened by the wall of red text. Dissect it calmly from top to bottom:

TypeError: Cannot read properties of undefined (reading 'toUpperCase')
    at formatUserProfile (user-service.ts:42:18)
    at renderHeader (header-component.ts:15:9)
    at initializeApp (main.ts:8:3)
  1. The Exception Type: TypeError indicates you called a method on an incompatible primitive.
  2. The Error Message: Cannot read properties of undefined (reading 'toUpperCase') tells you the variable holding the string was never initialized.
  3. The Culprit Frame: user-service.ts:42:18 gives you the exact file, line number, and column where the crash occurred.

7. Git Bisect: Automated Forensic Regression Hunting

When a feature was working last Tuesday but is broken today, and there are 150 commits between then and now, use git bisect:

git bisect start
git bisect bad                 # Current commit is broken
git bisect good abc1234        # Commit from last Tuesday was working

Git checks out the midpoint commit automatically. Test your app: if it works, run git bisect good; if it fails, run git bisect bad. In less than 8 steps, Git pinpoints the exact commit and author that introduced the regression.

Summary Table

Problem Scenario Amateur Approach Engineering Tool
Array of objects hard to read Spamming console.log() console.table()
Bug triggers on specific item in 5k loop Clicking Step Over 5,000 times Conditional Breakpoint
Unknown regression introduced this week Manually reading git commit diffs git bisect
Backend Node API error Blind restart with printed logs node --inspect + Chrome DevTools

Next Steps

Found this useful?
View all articles

Keep Reading

Related Articles

Learn with Dropout Developer

Build real software with AI

Step-by-step learning paths, vibe coding tutorials, and certified developer programs designed for the modern engineer.