Debugging and Error Handling7% of the exam

Console methods and breakpoints

Which console method answers which debugging question (table, dir, group, count, time and timeEnd, assert, trace), why a logged object can show later values, and how line, conditional and logpoint breakpoints, the debugger statement, stepping, the Scope and Call Stack panes, and pause-on-exception settings help you inspect running code.

Official exam objective
Given code to be debugged, use the console and breakpoints.

~6 min read · 10 practice questions ·

What the exam expects

  • Choose the console method for the job: table, dir, group, count/countReset, time/timeLog/timeEnd, assert, trace, and the log levels.
  • Predict console output, including why an expanded object can show values assigned after it was logged.
  • Pause code with a line breakpoint, a conditional breakpoint or a debugger statement, or log without pausing with a logpoint.
  • While paused, step over, into and out, and read the Scope and Call Stack panes; pause on caught or uncaught exceptions.
  • Key terms: log level (log, info, warn, error, debug: how the console classifies and filters a message); label (the string that names a counter or timer); conditional breakpoint (pauses only when an expression is true); logpoint (logs a message each time a line runs, without pausing); call stack (the chain of calls that led to the current line).

Key facts

console.table()
Detail
Displays tabular data as a table
console.dir()
Detail
Interactive property listing with disclosure triangles
console.count()
Detail
Counts per label; no label means "default"
console.timeEnd()
Detail
Stops the named timer and logs elapsed ms
console.timeLog()
Detail
Logs the timer's value; timer keeps running
console.assert()
Detail
Logs only when false; never throws
console.trace()
Detail
Outputs a stack trace without pausing
Logged objects
Detail
Browser shows contents when first viewed, not when logged
debugger;
Detail
Acts as a breakpoint only if debugging is available
Paused debugger panes
Detail
Watch expressions, Call stack, Scopes
Sources for this section (7)
  • Why can an expanded object in the browser console show values assigned after the `console.log` call?
  • When does a `debugger;` statement do nothing?
  • Which method logs once per call with a running count per label?
  • Why is `console.table()` better than `console.log()` for an array of 40 orders?

The questions are free to read. Answers with their sources and self-grading are included with the pack.

Keep reading with the JavaScript Developer pack

  • Core concepts
  • Exam traps
  • Worked scenario

The pack includes:

  • All 24 lessons of the JavaScript Developer guide, with reading progress
  • Interactive decision walks and step-by-step sequence steppers
  • Inline practice questions and one-click topic practice (10 questions for this lesson)
  • An official source cited for every claim
  • An AI tutor that answers from the guide
  • Unlimited timed practice exams

Practice for the JavaScript Developer exam