HTML DOM console.count() method
- Previous Page clear()
- Next Page error()
- Go to the Previous Level Window Console Object
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.
For more examples, please see 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(); }
Example 2
Call console.count() twice and see the result:
console.count(); console.count();
Example 3
Call console.log twice, set a label, and then see the result:
console.count("myLabel"); console.count("myLabel");
Example 4
To remove a label, use "" as the parameter:
console.count(""); console.count("");
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. |
Browser Support
The numbers in the table indicate the first browser version that fully supports this method.
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
console.count() | Support | Support | 30 | Support | Support |
- Previous Page clear()
- Next Page error()
- Go to the Previous Level Window Console Object