From 55189fa30d2a9aa157d2a25cddc59c0625a35c6b Mon Sep 17 00:00:00 2001 From: Paul Lee Date: Mon, 26 Oct 2026 16:19:19 +0700 Subject: [PATCH] doc: added example to group function in console.md Added example for group() in console documentation, including use of subsequent groupEnd() call in the example. Also added link for groupEnd() in group() description since they almost always will be used in pairs Signed-off-by: Paul Lee --- doc/api/console.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/api/console.md b/doc/api/console.md index 804778bd5fa6..e16f4a2ca225 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -372,7 +372,17 @@ Increases indentation of subsequent lines by spaces for `groupIndentation` length. If one or more `label`s are provided, those are printed first without the -additional indentation. +additional indentation. Use [`console.groupEnd()`][] to decrease indentation. + +```js +console.group('abc'); +// Prints: abc +console.log('inside group'); +// Prints: inside group, with 2 leading spaces +console.groupEnd(); +console.log('outside group'); +// Prints: outside group +``` ### `console.groupCollapsed()` @@ -620,6 +630,7 @@ This method does not display anything unless used in the inspector. The [`console.error()`]: #consoleerrordata-args [`console.group()`]: #consolegrouplabel +[`console.groupEnd()`]: #consolegroupend [`console.log()`]: #consolelogdata-args [`console.profile()`]: #consoleprofilelabel [`console.profileEnd()`]: #consoleprofileendlabel