Window Console Object
- Previous Page Window Object
- Next Page Window History
Console Object
The Console object provides access to the browser's debugging console.
The Console object is a property of the window object.
The Console object can be accessed in the following ways:
window.console
or simply console
Example
window.console.error("You made a mistake");
console.error("You made a mistake");
Console Object Methods
Method | Description |
---|---|
assert() | If assertion is false, write error messages to the console. |
clear() | Clear the console. |
count() | Record the number of times this specific call to count() has been made. |
error() | Output error messages to the console. |
group() | Create a new group in the console. |
groupCollapsed() | Create a new inline group in the console. However, the new group is created as collapsed. Users need to use the button to expand it. |
groupEnd() | Exit the current group in the console. |
info() | Output informational messages to the console. |
log() | Output messages to the console. |
table() | Display tabular data as a table. |
time() | Start a timer (to track how long an operation takes). |
timeEnd() | Stop the timer started by console.time(). |
trace() | Output stack trace to the console. |
warn() | Output warning messages to the console. |
- Previous Page Window Object
- Next Page Window History