Create a collapsed group of messages in the console:
console.log("Hello world!");
console.groupCollapsed();
console.log("Hello again, this time inside a collapsed group!");
Try it Yourself »
More examples below.
The groupCollapsed()
method starts a collapsed message group.
In the Console, click the expand button to open the new message group.
All new messages will now be written inside this group.
console.groupCollapsed(
label)
Parameter | Description |
label | Optional. A label for the group. |
End a group with console.groupEnd():
console.log("Hello world!");
console.groupCollapsed();
console.log("Hello again, this time inside a collapsed group!");
console.groupEnd();
console.log("and we are back.");
Try it Yourself »
Specify a label for the collapsed group:
console.log("Hello world!");
console.groupCollapsed("myLabel");
console.log("Hello again, this time inside a collapsed group, with a label!");
Try it Yourself »
console.groupCollapsed()
is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!