The
console.countReset() method is an inbuilt application programming interface of the console module which is used to reset the count for the specific label passed to it as a parameter.
Syntax:
console.countReset( label );
Parameters: This method has one parameter as mentioned above and described below:
- label: It is an optional parameter that specifies the label whose counter to be reset. Default value is "default".
Return Value: This method does not provide any output but reset the counter for the specified label.
Below examples illustrate the use of
console.countReset() method in Node.js:
Example 1:
Output:
a: 1
b: 1
a: 2
a: 3
a: 4
b: 2
a: 1
b: 1
Example 2:
Output:
default: 1
a: 1
b: 1
a: 2
a: 3
default: 2
default: 3
default: 1
a: 1
b: 1
Note: The above program will compile and run by using the
node filename.js command.
Reference: https://nodejs.org/api/console.html#console_console_countreset_label