GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — Console API - Web APIs | MDN

Console API

Baseline
Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

  • See full compatibility
  • Learn more

Note: This feature is available in Web Workers.

The Console API provides functionality to allow developers to perform debugging tasks, such as logging messages or the values of variables at set points in your code, or timing how long an operation takes to complete.

Concepts and usage

The Console API started as a largely proprietary API, with different browsers implementing it, albeit in inconsistent ways. The Console API spec was created to define consistent behavior, and all modern browsers eventually settled on implementing this behavior — although some implementations still have their own additional proprietary functions. Find out about these at:

  • Google Chrome DevTools implementation
  • Safari DevTools implementation

Usage is very simple — the console object contains many methods that you can call to perform rudimentary debugging tasks, generally focused around logging various values to the browser's Web Console.

By far the most commonly-used method is console.log(), which is used to log the current value contained inside a specific variable.

Interfaces

console

Provides rudimentary debugging functionality, including logging, stack traces, timers, and counters.

Examples

js
let myString = "Hello world";

// Output "Hello world" to the console
console.log(myString);

See the console reference page for more examples.

Specifications

Specification
Console
# console-namespace

Browser compatibility

See also

  • Tools
  • Web Console — how the Web Console in Firefox handles console API calls
  • about:debugging — how to see console output when the debugging target is a mobile device

Help improve MDN

Learn how to contribute

This page was last modified on Oct 25, 2024 by MDN contributors.

View this page on GitHub • Report a problem with this content
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.