Javascript console.group() Method

Introduction

Create a group of messages in the console:

Press F12 on your keyboard to view the message in the console view.

View in separate window

<!DOCTYPE html>
<html>
<body>
<script>

console.log("Hello world!");
console.group();
console.log("Hello again, this time inside a group!");

</script>/*from   w w  w .jav a  2s  .co  m*/

</body>
</html>

The console.group() method indicates the start of a message group.

All messages will from now on be written inside this group.

Use the console.groupEnd() method to end the group.

Use the console.groupCollapsed() method to hide the message group which is collapsed by default.

console.group(label);

Parameter Values

Parameter Type Description
label String Optional. A label for the group



PreviousNext

Related