Console count()

Examples

Call console.count() 5 times:

for (let i = 0; i < 5; i++) {
  console.count();
}
Try it Yourself »

Call console.count() 5 times, with a label:

for (let i = 0; i < 5; i++) {
  console.count("myLabel");
}
Try it Yourself »

More examples below.


Description

The count() method counts the number of times console.count() is called.

The count() method this number to the console.

Note

You can add a label that will be included in the console view.

As a default value the label "Default" is used.

See more examples in the bottom of this page.


Syntax

console.count(label)

Parameters

Parameter Description
label Optional.
Default label is "Default".


More Examples

Call console.count() two times:

console.count();
console.count();
Try it Yourself »

Call console.count two times, with a label:

console.count("myLabel");
console.count("myLabel");
Try it Yourself »

To remove the label, use "" as a parameter:

console.count("");
console.count("");
Try it Yourself »

Browser Support

console.count() is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.