console.log
General value inspection.
Console debugging helps you inspect values, flow and timing while code runs.
console.group("render");
console.log("items", items.length);
console.table(items);
console.groupEnd();
Errors & Debugging
console.log is useful, but the console has more tools: warn, error, table, group, time and trace.
Good console debugging is temporary and focused. Each log should explain what value or branch you are inspecting.
Remove noisy debug logs before production unless they are deliberate diagnostics behind a controlled setting.
General value inspection.
Readable arrays and objects.
Groups related output.
Measures elapsed time.
Examples
console.group("filter records");
console.log("input count", records.length);
console.log("active count", activeRecords.length);
console.groupEnd();
console.log(records); console.log(activeRecords); console.log(result); // What question are these logs answering?
Code patterns
These examples focus on the debugging patterns you will reuse: safe parsing, throwing, custom error types, console inspection, breakpoints and async failure handling.
View arrays of objects clearly.
console.table(records);
Keep related logs together.
console.group("render");
console.log("count", records.length);
console.groupEnd();
Measure a slow operation.
console.time("filter");
const active = records.filter((record) => record.active);
console.timeEnd("filter");
Find who called a function.
function render() {
console.trace("render called");
}
Rules that matter
Debugging starts before something breaks. Clear error types, helpful messages and visible failure states make the code easier to repair.
A value without context is hard to use.
Arrays of objects are easier to scan in tables.
It keeps the console readable.
Do not guess performance.
Do not ship noisy debugging.
Severity should mean something.
Production thinking
Debugging is faster when logs are written like answers to specific questions.
Console debugging should not replace visible user-facing error states.
Production diagnostics should be intentional, controlled and safe for sensitive data.
Console errors during render can reveal broken client-side content before publishing.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
A JavaScript feature is not production-ready until you know how it fails and how you will inspect that failure.