Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

console.count

Counts how many times this line was called.

Available since: Web API

Syntax

console.count(label)

Parameters

ParameterTypeDescription
labelstringOptional. 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: 2

Notes

Reset a counter with console.countReset(label). This example does not run on the site — open the browser console (F12).

See also

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.

Thanks for reading!

Donate to the site — we work hard for you.