JavaScript Console

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 15 Tutorials
DevTools

What You’ll Learn

The console object is your first debugging toolkit in JavaScript. This hub links to 14 method and 1 property tutorials covering logging, grouped output, tables, timers, assertions, stack traces, and heap stats.

01

log()

General output

02

warn / error

Severity levels

03

table()

Tabular data

04

group()

Nested logs

05

time()

Performance

06

15 guides

Full index

Introduction

JavaScript console methods help you inspect values, trace bugs, and understand program flow during development. In the browser, open DevTools with F12 or Ctrl+Shift+I (Windows) / Cmd+Option+I (Mac), then switch to the Console tab to see output.

What Are Console Methods?

They are functions on the global console object. Each method formats output differently—some add icons or colors, others build tables or measure elapsed time. They are meant for developers, not end users; strip or guard verbose logging before shipping to production.

💡
Beginner Tip

Start with console.log() to print variables. When something looks wrong, add console.warn() or console.error() so important messages stand out in DevTools.

Browser vs Node.js

  • Browser — logs appear in DevTools with clickable links to source lines.
  • Node.js — logs print to the terminal; most core methods behave similarly.
  • Production — prefer structured logging libraries or feature flags instead of raw console.log everywhere.

What Are Console Properties?

Unlike methods, properties are values you read directly on console without calling them. The most common example is console.memory in Chromium browsers, which exposes JavaScript heap usage (usedJSHeapSize, totalJSHeapSize, jsHeapSizeLimit). Properties are read-only snapshots—use methods like console.log(console.memory) to inspect them.

📝 Syntax

Call any method on the console object:

JavaScript
console.log("Hello, debugger!");
console.warn("Low disk space");
console.error("Request failed", statusCode);

Method groups

CategoryMethodsPurpose
Logginglog, info, warn, errorPrint messages at different severity levels
Structuregroup, groupEnd, tableOrganize complex output
Diagnosticsassert, trace, countValidate and measure behavior
Timingtime, timeEndBenchmark code blocks
UtilityclearReset the console view
PropertiesmemoryRead heap stats (Chrome; not a method call)

⚡ Quick Reference

GoalMethod
Print a valueconsole.log(value)
Highlight a warningconsole.warn(message)
Report an errorconsole.error(message)
Show objects as a tableconsole.table(data)
Measure durationtime(label) + timeEnd(label)
Log only if falseconsole.assert(condition, msg)

When to Use Which Methods

  • Quick inspectionconsole.log() for variables and intermediate results.
  • User-visible issuesconsole.warn() for recoverable problems.
  • Failuresconsole.error() inside catch blocks or API error handlers.
  • Lists of recordsconsole.table() for arrays of objects.
  • Multi-step flowsgroup() / groupEnd() for auth, fetch, or render pipelines.
  • Performance checkstime() / timeEnd() around slow functions.

👀 Console Output Preview

How different methods typically appear in DevTools:

Hello, debugger!
⚠ Warning: cache miss
✗ Error: HTTP 404

Console Tutorial Index

Search by method, property, or keyword. Methods and properties are grouped below. Each tutorial covers syntax, examples, and DevTools tips.

Methods — Getting Started

4 tutorials

Essential logging methods every developer uses daily.

TopicDescriptionTutorial
console.log()Prints messages or values to the console — the most common debugging tool.Open
console.info()Logs informational messages; in many browsers behaves like log() with an info icon.Open
console.warn()Logs a warning with a distinctive yellow style in DevTools.Open
console.error()Logs error messages, often with a red icon and optional stack formatting.Open

Methods — Debugging & Checks

4 tutorials

Validate assumptions, reset output, and inspect call stacks.

TopicDescriptionTutorial
console.assert()Logs a message only when the expression is false — useful for quick checks.Open
console.clear()Clears the console output for a fresh debugging view.Open
console.trace()Prints a stack trace from the current call site — great for “who called this?”Open
console.count()Counts how many times a labeled line runs; call countReset() to reset.Open

Methods — Grouping & Tables

4 tutorials

Structure noisy logs into readable groups and tables.

TopicDescriptionTutorial
console.group()Starts an expanded group to nest related log lines together.Open
console.groupCollapsed()Starts a collapsed group — click to expand in DevTools.Open
console.groupEnd()Closes the most recent group started with group() or groupCollapsed().Open
console.table()Displays arrays or objects as an easy-to-read table in the console.Open

Methods — Timing

2 tutorials

Measure how long code blocks take to run.

TopicDescriptionTutorial
console.time()Starts a timer with a label — pair with console.timeEnd() to measure duration.Open
console.timeEnd()Stops a timer started by time() and logs elapsed milliseconds.Open

Properties

1 tutorial

Readable values attached to the console object (not function calls).

TopicDescriptionTutorial
console.memoryChrome-only heap stats: jsHeapSizeLimit, totalJSHeapSize, and usedJSHeapSize (read-only).Open

Examples Gallery

Open DevTools Console (F12) and paste each snippet. Output appears in the Console panel, not on the page.

📚 Basic Logging

Print values and use severity levels.

Example 1 — Log Variables with console.log()

Inspect strings, numbers, and objects during development.

JavaScript
const user = { id: 1, name: "Ada" };
const count = 42;

console.log("User:", user);
console.log("Count:", count);
log() Tutorial

How It Works

console.log accepts multiple arguments. Objects are expandable in DevTools so you can drill into properties.

Example 2 — Warnings and Errors

Use different methods so important messages stand out visually.

JavaScript
const quota = 95;

if (quota > 90) {
  console.warn("Storage almost full:", quota + "%");
}

try {
  throw new Error("Network timeout");
} catch (err) {
  console.error("Fetch failed:", err.message);
}
warn() Tutorial

How It Works

warn() and error() do not stop execution—they only change formatting. Use them to signal severity to other developers.

📈 Structure & Timing

Organize output and measure performance.

Example 3 — Display Data with console.table()

Render an array of objects as columns instead of many log lines.

JavaScript
const products = [
  { sku: "A1", name: "Keyboard", price: 49 },
  { sku: "B2", name: "Mouse", price: 25 },
  { sku: "C3", name: "Monitor", price: 199 }
];

console.table(products);
table() Tutorial

How It Works

DevTools builds a table from object keys. Pass a second argument to show only selected columns.

Example 4 — Group Related Logs

Nest messages under a labeled header for multi-step operations.

JavaScript
function loadDashboard() {
  console.group("loadDashboard");

  console.log("Fetching user profile…");
  console.log("Fetching widgets…");
  console.warn("Widget cache stale — refreshing");

  console.groupEnd();
}

loadDashboard();
group() Tutorial

How It Works

group() opens an expanded tree. Use groupCollapsed() to start collapsed. Every group needs a matching groupEnd().

Example 5 — Measure Time with time() and timeEnd()

Benchmark how long a code block takes to run.

JavaScript
console.time("sumLoop");

let total = 0;
for (let i = 0; i < 1_000_000; i++) {
  total += i;
}

console.log("Total:", total);
console.timeEnd("sumLoop");
time() Tutorial

How It Works

The label string must match between time() and timeEnd(). For modern browsers, console.timeLog() can print intermediate marks.

💬 Usage Tips

  • Conditional logsconsole.assert(condition, msg) logs only when condition is false.
  • Clear clutter — run console.clear() between test runs.
  • Count loopsconsole.count("label") shows how often a line executes.
  • Find callersconsole.trace() prints the call stack at that moment.
  • Search this index — jump to any of 15 tutorials above.

⚠️ Common Pitfalls

  • Logging objects by reference — expanding an object later may show its final state, not the state at log time. Clone or log primitives when timing matters.
  • Leaving logs in production — exposes internals and can slow down apps; use build tools to strip logs.
  • Forgetting groupEnd() — unmatched groups make the console tree hard to read.
  • Mismatched time labelstimeEnd("a") will not stop time("b").
  • assert() confusion — it logs when the condition is false, unlike an if guard.

🧠 How Console Methods Work

1

Your code calls console

JavaScript invokes console.method(args) during execution.

Call
2

Runtime formats output

The browser or Node.js serializes values, adds icons, tables, or timers.

Format
3

DevTools displays it

Messages appear with source links so you can jump to the logging line.

Display
=

Faster debugging

You inspect state without altering program logic or adding UI.

Browser Support

Core methods like log(), warn(), error(), and clear() work in all modern browsers and Node.js. table() and grouping APIs are widely supported in current DevTools.

Baseline · DevTools API

console.* methods

Supported in Chrome, Firefox, Safari, Edge, and Node.js for local development. Styling and minor behavior may vary between runtimes.

99% Core methods
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
Console methods Excellent

Bottom line: Safe for debugging in every modern environment. Remove or gate verbose logs before production; console.memory is Chrome-only.

🎉 Conclusion

Console methods are essential for learning JavaScript and fixing bugs quickly. Master log(), severity levels, grouping, and tables first, then explore timing and assertions.

Use the searchable index to open all 15 tutorials. Each page includes syntax, try-it examples, and DevTools tips.

💡 Best Practices

✅ Do

  • Use descriptive log messages with context
  • Pick warn/error for real severity levels
  • Group logs for multi-step workflows
  • Remove or gate logs before production
  • Use breakpoints for complex logic

❌ Don’t

  • Log sensitive tokens or passwords
  • Rely on console as your only error reporting
  • Log inside tight loops without throttling
  • Assume users see console output
  • Forget matching groupEnd() calls

Key Takeaways

Knowledge Unlocked

Five things to remember about console methods

Your gateway to 15 debugging tutorials.

5
Core concepts
! 02

Levels

warn, error

Severity
tbl 03

table()

Column view

Data
{ } 04

group()

Nested logs

Structure
15 05

Index

Search all

Ref

❓ Frequently Asked Questions

console is a built-in object for logging and debugging. In browsers it writes to DevTools; in Node.js it writes to the terminal. It is not part of the language spec for user-facing apps — remove or gate logs in production.
In most browsers both print a message. info() may show an info icon in DevTools. Functionally they are similar; use warn() or error() when severity matters.
Use console.table() when you want to inspect arrays of objects or key-value data in column form. It is faster to scan than a long series of log() calls.
console.time(label) starts a timer. console.timeEnd(label) stops it and logs elapsed time in milliseconds. Use the same label string for both calls.
Yes. Node.js implements the console object. console.log, console.error, console.table, and most browser methods work in Node, though styling may differ.
Read the overview, open DevTools (F12), try the five examples, then open console.log() from Getting Started. Use the search box to find any of the 14 method tutorials.
Did you know?

In DevTools you can pass format specifiers to console.log like %s (string), %d (number), and %o (object) for styled, structured output—similar to printf in other languages.

Start with console.log()

The fastest way to see what your code is doing — open DevTools and log your first variable.

log() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful