Node.js console.group() Method
The console. group() method is an inbuilt application programming interface of the console module which is used to print passed content in a grouped style. It indicates the start of a message group. To end this group we can use console. groupEnd() method.
Parameters: This method accepts only one parameter as mentioned above and described below:
- label: The label for the group which you are grouping on the console. This parameter is not mandatory, it’s optional and can be run console. group() method without passing label parameter.
- Type: String
- Required: Optional
Return Value: This method doesn’t return anything but group the content on the console with a label if provided otherwise simply without a label.
Below examples illustrate the use of console. group() method in Node.js.
Run index.js file using below command:
GeeksforGeeks 1st print from the first group 2nd print from the first group
GeeksforGeeks ========================== This is the starting main group 1st group and not from any nested group Starting of the 1st Nested group Hello Geeks for Geeks from 1st Main Nested group Computer Science Portal(GeeksforGeeks) from 1st Main Nested group Starting of the 2nd Main Nested group Hello from 2nd Main Nested group Hello from 2nd Main Nested group Now Main group will end This the Hello from GeeksforGeeks from outside the Main Group ===========================