Console Method Reference in JS
* -⊝- - the method is not used in this environment;
* ± - the method is used, but with features (visible in the tooltip);
* `+` - a full-fledged implementation of the method.
assert (expression [, object, ...])
If the expression expression is false, console.error outputs; otherwise, nothing is output.
Clears the console window.
Each time displays the number of passes of a given point in the code. If there is an object argument , then object.toString () is displayed before the counter value.
|+||+||+ (30.0+)||+||-⊝-||+||± ...|
debug (object [, object, ...])
Equivalent to console.log for compatibility with the old version of the console object, when .debug additionally displayed a link to the line of code from which it was called.
|equals .log ()||+||+||+||+||-⊝-||+||± ...|
|+||+||+ (8+)||+ (9+)||+||+||+|
The object XML is displayed.
|+||+||-⊝-||+ (11+)||-⊝-||+||± ...|
error (object [, object, ...])
The result of console.trace also displays the error for the place from where it was called (without stopping the execution of the program). Patterns (% s,% d (% i),% f,% o,% O,% c) are supported, as in console.log. Call stack trace example (Firefox 31+):
|+||± ...||+||+ (8+)||+||+||± ...|
exception (object [, object, ...])
Equivalent to error ()
|equals .error ()||-⊝-||-⊝-||+ (28+)||-⊝-||-⊝-||-⊝-||-⊝-|
group (object [, object, ...])
Begins an expanded group of entries in the console, which can then be manually collapsed. The group ends with the .groupEnd () command. Patterns are supported (see .log () ). Example code and result (from the article " Features of the browser console ", 2013):
|+||+||± ...||+ (11+)||-⊝-||+ (4+)||+|
groupCollapsed (object [, object, ...])
Begins the initially collapsed group of entries in the console, which can then be expanded manually. The group ends with the .groupEnd () command. Patterns are supported (see .log () ).
|+||+||± ... (9+)||+ (11+)||-⊝-||+ (5.1+)||+|
It marks the end of a group of log messages that are able to collapse-expand (except for Firefox) manually.
|+||+||+ (9+)||+ (11+)||-⊝-||+ (4+)||+|
info (object [, object, ...])
It is similar to .log (), but it is executed in a different design for distinguishing between types of messages, for example, for gradation of importance or for other semantic meaning of this group of messages. Patterns are supported (described in .log () ). Example differences for Firebug, Chrome, IE9:
log (object [, object, ...])
Outputs arguments to the console, separated by spaces. The most popular of the console commands.
It supports patterns - special names in the first argument, indicating that it should be used as a template into which the following arguments will be substituted for the terms (as in printf () in C, but much simpler). Examples:
Types of patterns and the type of the data into which the value of the substituted argument is converted:
% s - string.
% d or % i is a number.
% f is a floating-point number (Firebug also supports).
% o - DOM element (Firebug displays as a link to an element. Chrome, in addition to a link, displays an element in the console. Firefox clicks on an element in a modal window (all attributes and methods of this object are available).
% O - JS object (not supported in Firefox; Chrome converts the DOM object to a js object for this pattern; Firebug does not distinguish % o from % O ).
% c- CSS-style (color, background, font; in Firefox - from version 31). An example of styling with the% c pattern (Firefox):
An analogue of .timeStamp () for Safari, but .timeStamp () is not supported in it, and vice versa.
|= .timeStamp ()||-⊝-||-⊝-||-⊝-||-⊝-||-⊝-||+||-⊝-|
table (data [, columns])
Two-dimensional tabular data - in table format. Data - an array or an object (or an object from objects, an object from arrays), each element of which will be a row in the table. The first column of a two-dimensional array will be its index (from 0). Or, if it is an object, the first column will consist of the keys of the object. Example from Firefox (object of objects):
Columns - an additional array of column names for table headers, if the rows are created from arrays, and we do not want the names to be numeric indices. Above - there was an example of a result (Firefox) obtained either from named columns or from an object of objects. Below is what would be from an array of arrays without the columns parameter:
Turns on the counter (milliseconds) under the name label.
|+||+||+ (10+)||+ (11+)||+||+ (4+)||±|
Stops the counter (milliseconds) under the name label and publishes the result under this name. Example (Chrome):
|+||+||+ (10+)||+ (11+)||+||+ (4+)||±|
Draws timestamps on the script timing diagram, which allows you to monitor the dynamics of the program. Example (Firebug):
Shows the stack trace of the function at the moment of execution (the same as usually shown when stopping at the place of the error). An example in Safari (in the sidebar), in Chrome (in the console):
|+||+||+ (10+)||+ (11+)||+||+ (7.0.1+)||± ...|
warn (object [, object, ...])
It is similar to .log () and .info (), but is issued in a different design to distinguish message types. Patterns are supported (described in .log () ).
throw new Error ('mesasge');
• Console API Reference for Chrome
• Console API in Firebug
• Console object (MDN)
• Console object in IE10 (MSDN)
• in Node.js v0.12.0
• ... in Safari Web Inspector Guide
• Console in Opera Dragonfly
• Use the console to the full
• Firebug 1.6 (console.table) release
• Using the F12 Tools Console to View Errors and Status (MSDN)
• ... + much more - Firefox Developer Tools Episode 31 - console stack traces, styled console logs in Fx31.
• FireBug * Console API - describes the subtleties of implementation seen in browser tests in 2013;
UPD console API : so that everyone can perfect this description, translate it into another language, make updates as browsers evolve , the code is laid out on Github and the foundations of multilingualism and the ability to add your own spoiler to this plate (spoilers in article, of course, tied to the publication site). (The root of the description is the English version, but the markup of the table on the Github should be brought to quality).
UPD: in the comment there was a suggestion to do sorting by columns (to separate methods unsupported for this environment). If (on Githaba.io) the descriptions with spoilers are driven in one row, it will be possible to use a standard script sorter (are there any enthusiasts? Write to the LAN or issue if you need to agree on the layout, because I will somehow do the spoilers).
UPD 2015-03-21: spoilers, viewing modes and HTML are more flexible than in this publication. Not only in this and fully expanded form , but also in a more dense form , 1 method per row of the table, with the possibility of 1 click to switch between them. English version .