Console Methods Beyond console.log That Save Debugging Time
You add console.log to a loop, refresh, and the panel fills with 400 identical lines of "[object Object]" and "here". Ten minutes later you are scrolling and squinting instead of fixing the bug.

You add console.log to a loop, refresh, and the panel fills with 400 identical lines of "[object Object]" and "here". Ten minutes later you are scrolling and squinting instead of fixing the bug. Most developers use one or two console methods for years, while the browser ships about twenty that solve exactly this kind of mess.
I edit our tooling coverage and spend a fair part of each week inside DevTools, in Chrome, Firefox and Safari. Below are the console methods I actually reach for, what each one is good at, and the cases where a debugger beats all of them.
Why console.log stops scaling
console.log is perfect for a quick check of one value. It starts failing when you need to compare many objects, trace how often something runs, or find where in a call stack a function was triggered. Three problems show up again and again:
- Arrays of objects print as collapsed trees you have to click open one by one.
- Logs from different parts of the app interleave, so you cannot tell which line belongs to which flow.
- Logged objects are live references in Chrome and Firefox. Expand one later and you see its current state, not its state when it was logged.
That last one bites people constantly. If you need a snapshot, log JSON.parse(JSON.stringify(obj)) or structuredClone(obj) instead of the object itself.
Console methods for reading data
console.table
Pass it an array of objects and it renders a sortable table with one row per item and one column per property. For an API response with 50 users, console.table(users) is readable in two seconds where console.log takes two minutes. A second argument limits the columns, for example console.table(users, ["id", "email", "role"]).
console.dir
For DOM elements, console.log prints the HTML tree, while console.dir prints the element as a JavaScript object with all its properties. Use it when you need to see dataset values, event handler properties or computed attributes rather than markup.
console.group and console.groupCollapsed
Wrap related logs between console.group("checkout flow") and console.groupEnd(). The output nests under a collapsible label. groupCollapsed starts closed, which keeps noisy flows out of the way until you need them. Groups can nest, so a request handler group can contain a validation group and a database group.
Styled output with %c
Any log can be styled by adding %c to the message and passing a CSS string as the next argument, for example console.log("%cAuth", "color: white; background: purple; padding: 2px 6px"). It sounds like decoration, but when three subsystems log at once, a coloured tag per subsystem makes the panel scannable at a glance. Keep the styles short and consistent across the team, or it turns into noise of a different kind.
Console methods for timing and counting
| Method | What it does | Typical use |
|---|---|---|
| console.time("label") and console.timeEnd("label") | Measures elapsed milliseconds between the two calls | Rough timing of a parse or render step |
| console.timeLog("label") | Prints elapsed time without stopping the timer | Checkpoints inside a long function |
| console.count("label") | Prints how many times this line has run | Spotting unexpected re-renders or duplicate handlers |
| console.countReset("label") | Resets that counter to zero | Counting per user action |
console.count has saved me more time than any other method on this list. A React component that renders 14 times on one click, or a scroll handler attached three times, shows up immediately as a climbing number.
Treat console.time as a rough gauge, though. It measures wall clock time including anything else the main thread was doing. For real profiling, use the Performance panel. It records every function call, layout and paint, and shows you where the time actually went rather than how long a block took while other work was competing with it. A console timer that reports 120 ms can hide 90 ms of garbage collection that has nothing to do with your code.
Console methods for tracing and filtering
- console.trace() prints the full call stack at that point. Perfect for "who is calling this function with null?" questions.
- console.assert(condition, message) logs only when the condition is false. A line such as console.assert(user.id, "missing user id") stays silent through thousands of calls and speaks up only on the one that matters.
- console.warn and console.error show with yellow and red styling and include a stack trace. They can also be filtered by level in the console toolbar, so using them correctly lets you hide your info logs with one click.
- console.debug is hidden by default in Chrome unless you enable Verbose. Good for chatty logs you want available but not visible.
Stack traces from these methods point to your original source files only if source maps are working. If they point into a minified bundle, read our explainer on why source maps matter.
When not to reach for the console at all
A lot of debugging advice treats better logging as the answer to everything. I disagree. Logging is great for questions about frequency, order and shape of data. It is slow for questions about state at a specific moment, because every new question means editing code, saving and reloading.
If you find yourself adding a fifth log line to the same function, switch to a breakpoint. Pausing execution lets you inspect every variable in scope, step line by line and evaluate expressions on the spot, with no rebuild. The DevTools features most developers never open include logpoints, which are breakpoints that print a message without pausing and without touching your source code. They are the best of both approaches.
And when a bug appeared at some point in the last 200 commits and you cannot find it by reading code, neither logging nor breakpoints are the fastest route. Git bisect narrows it to one commit in about eight steps.
Keep console methods out of production
Stray logs in production leak internal data, clutter user consoles and cost a little performance in hot paths. A few habits help:
- Add the ESLint no-console rule as a warning, allowing warn and error.
- Strip console calls at build time. Most bundlers and minifiers have a drop console option for production builds.
- Use a tiny logger wrapper that checks an environment flag, so you can turn verbose logs back on for a single user when debugging a live issue.
Frequently asked questions
What is the difference between console.log and console.dir?
For most values they look similar. The difference shows with DOM elements: console.log prints the element as HTML markup, while console.dir prints it as a JavaScript object with its properties. Use console.dir when you need properties rather than structure.
How do I log a table in the browser console?
Call console.table with an array or an object. Each item becomes a row and each property becomes a column, and you can click headers to sort. Pass an array of column names as the second argument to show only those columns.
Does console.log slow down JavaScript?
A few calls make no noticeable difference. Thousands of calls inside a loop or animation frame can slow things down, especially with DevTools open and large objects being logged. Remove or strip logs from production builds to avoid the cost entirely.
More in Dev Tools
Dev Tools
How to Use the DevTools Coverage Tab to Find Dead CSS
A stylesheet on a project I inherited was 184KB minified, one file for the whole site.
Dev Tools
How to Use curl Timing to Find Why an API Request Is Slow
"The API is slow" is one of the least useful bug reports, and also one of the most common.
Dev Tools
Git Rebase vs Merge and How to Choose for Your Team
Your feature branch is three days old, main has moved on by 40 commits, and the pull request page says "This branch is out of...