Easy Tutorial
❮ Prop Form Method Prop Html Title ❯

HTML DOM console.count() Method

Console Object

Example

Logs the number of times count() is called and outputs to the console:


Definition and Usage

console.count() writes the number of times it has been called to the console.

The console.count() method can include a label.


Syntax

console.count(label)

Browser Support

The numbers in the table specify the first browser version that fully supports the method.

Method
console.count() Yes Yes 30 Yes Yes

Parameter Values

Parameter Type Description
label String Optional. If specified, it outputs the label to the console, which appears before the count.

More Examples

Example

Call console.count() twice to see the result:

Example

Call console.count() twice with a label to see the result:

Each call to console.count() increments the count by 1 if the label is the same. If the label is different, it starts counting anew.

Console Object

❮ Prop Form Method Prop Html Title ❯