JavaScript Console Methods

About This Index
This page is the JavaScript Console Methods index for the tutorial track. Each row names a console method and what that call prints or measures.
Learn what the console is on /js/console. Use this page when you need a specific call such as console.log(), console.table(), or console.time().
Start with log(), warn(), and error(). Then look up assert(), table(), group(), and time().
How to Call a Console Method
Every method in this index is called on console:
const rows = [
{ name: "Ada", score: 80 },
{ name: "Lin", score: 91 }
];
console.log(rows[0].name); // "Ada"
console.warn("Retrying");
console.table(rows);
console.time("load");
console.timeEnd("load"); JavaScript Console Methods Table
All console methods in this JavaScript tutorial series (14 methods).
Logging
4 methodsPrint a value, a note, a warning, or an error while you learn a JavaScript program.
| Method | Description | Tutorial |
|---|---|---|
console.log() | Prints a message or value. The usual first call in a JavaScript tutorial. | On this index |
console.info() | Prints an informational message. In many browsers it looks like log() with an info icon. | On this index |
console.warn() | Prints a warning. DevTools usually shows it in yellow so it stands out from normal logs. | On this index |
console.error() | Prints an error message, often in red, with a stack trace when you pass an Error. | On this index |
Checks and traces
4 methodsConfirm a condition, reset the panel, count calls, and see the call stack.
| Method | Description | Tutorial |
|---|---|---|
console.assert() | Prints a message only when the condition is false. A true condition stays quiet. | On this index |
console.clear() | Clears the visible console messages so the next run starts on a clean panel. | On this index |
console.count() | Counts how many times a label has been logged. Pair it with countReset() to start over. | On this index |
console.trace() | Prints a stack trace from the line where you called it, so you can see who called the function. | On this index |
Groups and tables
4 methodsNest related log lines, or print a list of records as a table.
| Method | Description | Tutorial |
|---|---|---|
console.group() | Opens an expanded group so the next log lines nest under one heading. | On this index |
console.groupCollapsed() | Opens a collapsed group. In DevTools you expand it when you want the details. | On this index |
console.groupEnd() | Closes the group most recently opened with group() or groupCollapsed(). | On this index |
console.table() | Prints an array or an array of objects as a table with columns. | On this index |
Timers
2 methodsMeasure how long a block of JavaScript takes to run.
| Method | Description | Tutorial |
|---|---|---|
console.time() | Starts a named timer. Call timeEnd() with the same label to print the elapsed time. | On this index |
console.timeEnd() | Stops the timer from time() and prints how many milliseconds passed. | On this index |
Frequently Asked Questions
Start with the Console lesson
See log(), warn(), and count() print real lines, then come back to this index.
10 people found this page helpful
