HTML DOM console.count() method

Definition and usage

Write the number of calls to a specific console.count() to the console.

You can add labels that are included in the console view. By default, the label "default" will be added.

See more examples at the bottom of this page.

Instance

Example 1

Write the number of times console.count() will be called within the loop to the console:

for (i = 0; i < 10; i++) {
  console.count();
}

Try it yourself

Example 2

Call console.count() twice and view the result:

console.count();
console.count();

Try it yourself

Example 3

Call console.log twice, set a label, and then see the result:

console.count("myLabel");
console.count("myLabel");

Try it yourself

Example 4

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

console.count("");
console.count("");

Try it yourself

Syntax

console.count(label)

Parameter value

Parameter Type Description
label String Optional. If provided, this method will calculate the number of times console.count() is called with this label. If not provided, the label "default" will be added.

Browserkompatibilität

Die in der Tabelle angegebenen Zahlen zeigen die erste Browserversion an, die die Methode vollständig unterstützt.

Methode Chrome IE Firefox Safari Opera
console.count() Unterstützung Unterstützung 30 Unterstützung Unterstützung