HTML DOM console.group() method
Example
Create a group of information on the console:
console
.
log
(
"
Runoob
"
)
;
console
.
group
(
)
;
console
.
log
(
"
Runoob, this is inside the group.
"
)
;
Try it »
Definition and Usage
The console.group() method is used to set the starting position of grouped information; all information after this position will be written into the group.
Tip: Use console.groupEnd() method to end the current group.
Tip: Use console.groupCollapsed() method to hide the grouped information.
Syntax
console.group(label)
Browser support
The numbers in the table indicate the first browser version that supports this method.
| Method | |||||
|---|---|---|---|---|---|
| console.group() | Yes | 11.0 | 4.0 | 4.0 | Yes |
Parameter Description
| Parameters | Type | Description |
|---|---|---|
| label | String | Optional. The group label. |
More examples
Example
Use the console.groupEnd() method to end the group:
console
.
log
(
"
Runoob
"
)
;
console
.
group
(
)
;
console
.
log
(
"
Runoob, this is inside the group.
"
)
;
console
.
groupEnd
(
)
;
console
.
log
(
"
Out of the group!
"
)
;
Try it »
Example
Set a label for the information group:
console
.
log
(
"
Runoob
"
)
;
console
.
group
(
"
RunoobLabel
"
)
;
console
.
log
(
"
I am in the group with the specified label.
"
)
;
Try it »
Console object