English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
console.group()method creates a new inline group in the console.
This will indent the console messages by an additional level untilconsole.groupEnd()up to.
The console.group() method uses an optional parameterlabel.
console.group(label)
console.log("Hello!"); console.group(); console.log("Hello again, this time inside the group!"); console.group(); console.log("Hello again, this time within another group!");Test and see‹/›
All browsers fully support the console.group() method:
Method | |||||
console.group() | Is | Is | Is | Is | Is |
Parameter | Description |
---|---|
label | (Optional) Group Label |
Call console.group() four times, and withlabel:
console.group("Level 1"); console.group("Level 2"); console.group("Level 3"); console.group("Level 4");Test and see‹/›
Use the console.groupEnd() method to end the group:
console.log("This is the outer level"); console.group(); console.log("Level 2"); console.group(); console.log("Level 3"); console.warn("More of level 3"); console.groupEnd(); console.log("Back to level 2"); console.groupEnd(); console.log("Back to the outer level");Test and see‹/›