Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
12
4
3
18
1

The console.assert() static method writes an error message to the console if the assertion is false. If the assertion is true, nothing happens.

2
12
28
4
18
3.2

The console.clear() static method clears the console if possible.

25
12
39
7
25
7

The console.count() static method logs the number of times that this particular call to count() has been called.

2
12
30
4
18
3.2

The console.countReset() static method resets counter used with console/count_static.

68
79
62
13
68
13

The console.debug() static method outputs a message to the console at the "debug" log level. The message is only displayed to the user if the console is configured to display debug output. In most cases, the log level is configured within the console UI. This log level might correspond to the Debug or Verbose log level.

2
12
5
4
18
3.2

The console.dir() static method displays a list of the properties of the specified JavaScript object. In browser consoles, the output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.

2
12
8
4
18
3.2

The console.dirxml() static method displays an interactive tree of the descendant elements of the specified XML/HTML element. If it is not possible to display as an element the JavaScript Object view is shown instead. The output is presented as a hierarchical listing of expandable nodes that let you see the contents of child nodes.

2
12
39
4
18
3.2

The console.error() static method outputs a message to the console at the "error" log level. The message is only displayed to the user if the console is configured to display error output. In most cases, the log level is configured within the console UI. The message may be formatted as an error, with red colors and call stack information.

1
12
4
3
18
1

The console.group() static method creates a new inline group in the Web console log, causing any subsequent console messages to be indented by an additional level, until console/groupEnd_static is called.

2
12
9
4
18
3.2

The console.groupCollapsed() static method creates a new inline group in the console. Unlike console/group_static, however, the new group is created collapsed. The user will need to use the disclosure button next to it to expand it, revealing the entries created in the group.

6
12
9
5.1
18
5

The console.groupEnd() static method exits the current inline group in the console. See Using groups in the console in the console documentation for details and examples.

2
12
9
4
18
3.2

The console.info() static method outputs a message to the console at the "info" log level. The message is only displayed to the user if the console is configured to display info output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as a small "i" icon next to it.

1
12
4
3
18
1

The console.log() static method outputs a message to the console.

1
12
4
3
18
1
substitution_strings

Substitution strings

1
12
9
3
18
1

The console.table() static method displays tabular data as a table.

27
13
34
7
27
7

The console.time() static method starts a timer you can use to track how long an operation takes. You give each timer a unique name, and may have up to 10,000 timers running on a given page. When you call console/timeEnd_static with the same name, the browser will output the time, in milliseconds, that elapsed since the timer was started.

2
12
10
4
18
3.2

The console.timeEnd() static method stops a timer that was previously started by calling console/time_static.

2
12
10
4
18
3.2

The console.timeLog() static method logs the current value of a timer that was previously started by calling console/time_static.

71
79
62
13
71
13

The console.trace() static method outputs a stack trace to the console.

2
12
6
4
18
3.2

The console.warn() static method outputs a warning message to the console at the "warning" log level. The message is only displayed to the user if the console is configured to display warning output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as yellow colors and a warning icon.

1
12
4
3
18
1
worker_support

Available in workers

31
12
29
7
31
7
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 1 item(s)
Implementation note
  • In version 28, if a negative value is passed to %d, it will be rounded down to the closest negative integer, so -0.1 becomes -1.
Notes 2 item(s)
Implementation note
  • Before Edge 79, `%c` is not supported.
  • Before Edge 79, `%d` outputs a 0 if the specified value isn't a number.
Notes 1 item(s)
Implementation note
  • In version 28, if a negative value is passed to %d, it will be rounded down to the closest negative integer, so -0.1 becomes -1.

Syntax

JAVASCRIPT
console.log("Failed to open the specified link");

Use cases

  • Using Console

    The console object provides access to the debugging console (e.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.