Window.console

The Window.console read-only property returns a reference to the Console object, which provides methods for logging information to the browser's console. These methods are intended for debugging purposes only and should not be relied on for presenting information to end users.

Syntax

JavaScript
var consoleObj = window.console;

Examples

Logging to console

The first example logs text to the console.

JavaScript
console.log("An error occurred while loading the content");

The next example logs an object to the console, with the object's fields expandable using disclosure widgets:

JavaScript
console.dir(someObject);

See "Usage" in Console for more thorough examples.

Specifications

Specification Status Comment
Console API Living Standard Initial definition.

Currently there are many implementation differences among browsers, but work is being done to bring them together and make them more consistent with one another.

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/window/console

API console Console Property Read-only Reference Window