console.count
Counts how many times this line was called.
Available since: Web API
Syntax
console.count(label)Parameters
| Parameter | Type | Description |
|---|---|---|
| label | string | Optional. The counter name. default by default. |
Return value
undefinedReturns nothing.
Examples
How many times a function ran (output in the browser console):
function render(page) {
console.count(page);
}
render('home');
render('about');
render('home');Output:
home: 1
about: 1
home: 2Notes
Reset a counter with console.countReset(label). This example does not run on the site — open the browser console (F12).
See also
- console.time — Measures how long code took to run.
- console.log — Prints values to the console.
In the tutorial
- Debugging — How to find bugs in JavaScript: reading the error message, console.log and its variants, checking types, developer tools and debugger.