Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM console.count() method

HTML DOM console.count() method

Console Object Console object

Example

Record the number of count() calls and output it to the console:

for

(

i

=

0

;

i

<

10

;

i

++

)

{

console

.

count

(

)

;

}

Try it »


Definition and Usage

console.count() writes the number (call count) to the console when called.

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


Syntax



console.count(label)


Browser support

The numbers in the table indicate the first browser version that supports this method.

Method
console.count() Yes Yes 30 Yes Yes

Parameter Description

Parameters Type Description
label String Optional. If specified, the label is output to the console and shown before the call count.

More examples

Example

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

console

.

count

(

)

;

console

.

count

(

)

;

Try it »

Example

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

console

.

count

(

"

Runoob

"

)

;

console

.

count

(

"

Runoob

"

)

;

console

.

count

(

"

Runoob2

"

)

;

Try it »

Each time console.count() is called, if the labels are the same, the corresponding number increases by 1; otherwise counting starts over.

Console Object Console object