- Node.js Tutorial
- Node.js - Home
- Node.js - Introduction
- Node.js - Environment Setup
- Node.js - First Application
- Node.js - REPL Terminal
- Node.js - Command Line Options
- Node.js - Package Manager (NPM)
- Node.js - Callbacks Concept
- Node.js - Upload Files
- Node.js - Send an Email
- Node.js - Events
- Node.js - Event Loop
- Node.js - Event Emitter
- Node.js - Debugger
- Node.js - Global Objects
- Node.js - Console
- Node.js - Process
- Node.js - Scaling Application
- Node.js - Packaging
- Node.js - Express Framework
- Node.js - RESTFul API
- Node.js - Buffers
- Node.js - Streams
- Node.js - File System
- Node.js MySQL
- Node.js - MySQL Get Started
- Node.js - MySQL Create Database
- Node.js - MySQL Create Table
- Node.js - MySQL Insert Into
- Node.js - MySQL Select From
- Node.js - MySQL Where
- Node.js - MySQL Order By
- Node.js - MySQL Delete
- Node.js - MySQL Update
- Node.js - MySQL Join
- Node.js MongoDB
- Node.js - MongoDB Get Started
- Node.js - MongoDB Create Database
- Node.js - MongoDB Create Collection
- Node.js - MongoDB Insert
- Node.js - MongoDB Find
- Node.js - MongoDB Query
- Node.js - MongoDB Sort
- Node.js - MongoDB Delete
- Node.js - MongoDB Update
- Node.js - MongoDB Limit
- Node.js - MongoDB Join
- Node.js Modules
- Node.js - Modules
- Node.js - Built-in Modules
- Node.js - Utility Modules
- Node.js - Web Module
- Node.js Useful Resources
- Node.js - Quick Guide
- Node.js - Useful Resources
- Node.js - Dicussion
NodeJS - console.groupEnd() Method
The Node.js console.groupEnd() method is an inbuilt method of Console class.
The Node.js console.groupEnd() method of node.js will end the group which was created with console.group() and console.groupCollapsed() methods.
This method marks the end of the group. It is used to end a previously started console grouping; it can be used along with the console.group() method.
It creates a new group of indented messages within the output for easier reading and organization. Now let's dive into syntax and usage of console.groupEnd() method of Node.js.
Syntax
Following is the syntax of Node.js console.groupEnd() method −
console.groupEnd();
Parameters
This method does not accept any parameters.
Return value
This method will return nothing instead, it ends the group on the console.
Example
In this example, we are creating a group with the Node.js console.group() method and writing some messages with the console.log() function. Then we are ending the group by calling the Node.js console.groupEnd() method.
console.group("GROUP 1"); console.log("Knock knock....first message in Group 1"); console.log("Knock knock....second message in Group 1") console.log("Done with the messages, closing the group now"); console.groupEnd(); console.log("group is ended");
Output
As we can see in the output from the below figure, we have ended the group.
GROUP 1 Knock knock....first message in Group 1 Knock knock....second message in Group 1 Done with the messages, closing the group now group is ended
Example
In this example, we are creating a group with the console.groupCollapsed() method and writing some messages with the console.log() function. Then we are ending the group by calling the console.groupEnd() method.
console.groupCollapsed("Collapsed group"); console.log("Knock knock....first message in Collapsed group"); console.log("Knock knock....second message in Collapsed group") console.log("Done with the messages, closing the group now"); console.groupEnd(); console.log("group is ended")
Output
Collapsed group Knock knock....first message in Collapsed group Knock knock....second message in Collapsed group Done with the messages, closing the group now group is ended
To understand better, execute the above code in the browser's console. Following is the output of the above program in the browser's console.
As the group is created with the console.groupCollapsed() method, we need to extract the inner messages. Then we ended the group with the console.groupEnd() method.
Example
In this example, we are creating nested groups. We are creating a parent group with the console.group() method and the nested methods with the console.groupCollapsed() method. Then we are ending all the groups sequentially.
console.group("GROUP 1"); console.log("Knock knock....first message in Group 1"); console.log("Knock knock....second message in Group 1") console.log("Done with the messages, closing the group now"); console.groupCollapsed("Nested group 1"); console.log("Knock knock....first message in Nested group 1"); console.log("Knock knock....second message in Nested group 1") console.log("Now we are entering into another group inside nested group"); console.groupCollapsed("inner nested group"); console.log("OOPS! no messages here."); console.groupEnd(); console.log("inner nested group ended"); console.groupEnd(); console.log("Nested group ended"); console.log("GROUP 1 ended");
Output
GROUP 1 Knock knock....first message in Group 1 Knock knock....second message in Group 1 Done with the messages, closing the group now Nested group 1 Knock knock....first message in Nested group 1 Knock knock....second message in Nested group 1 Now we are entering into another group inside nested group inner nested group OOPS! no messages here. inner nested group ended Nested group ended GROUP 1 ended
To Continue Learning Please Login
Login with Google