{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.0.json","id":"console","path":"/console","type":"module","module":"console","title":"Console","introducedIn":"v0.10.13","sourceLink":{"path":"lib/console.js","url":"https://github.com/nodejs/node/blob/HEAD/lib/console.js"},"stability":{"index":"2","description":"Stable"},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `node:console` module provides a simple debugging console that is similar to\nthe JavaScript console mechanism provided by web browsers.\n\nThe module exports two specific components:\n\n* A `Console` class with methods such as `console.log()`, `console.error()`, and\n  `console.warn()` that can be used to write to any Node.js stream.\n* A global `console` instance configured to write to [`process.stdout`](process.html#processstdout) and\n  [`process.stderr`](process.html#processstderr). The global `console` can be used without calling\n  `require('node:console')`.\n\n***Warning***: The global console object's methods are neither consistently\nsynchronous like the browser APIs they resemble, nor are they consistently\nasynchronous like all other Node.js streams. Programs that desire to depend\non the synchronous / asynchronous behavior of the console functions should\nfirst figure out the nature of console's backing stream. This is because the\nstream is dependent on the underlying platform and standard stream\nconfiguration of the current process. See the [note on process I/O](process.html#a-note-on-process-io) for\nmore information.\n\nExample using the global `console`:\n\n```js\nconsole.log('hello world');\n// Prints: hello world, to stdout\nconsole.log('hello %s', 'world');\n// Prints: hello world, to stdout\nconsole.error(new Error('Whoops, something bad happened'));\n// Prints error message and stack trace to stderr:\n//   Error: Whoops, something bad happened\n//     at [eval]:5:15\n//     at Script.runInThisContext (node:vm:132:18)\n//     at Object.runInThisContext (node:vm:309:38)\n//     at node:internal/process/execution:77:19\n//     at [eval]-wrapper:6:22\n//     at evalScript (node:internal/process/execution:76:60)\n//     at node:internal/main/eval_string:23:3\n\nconst name = 'Will Robinson';\nconsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to stderr\n```\n\nExample using the `Console` class:\n\n```js\nconst out = getStreamSomehow();\nconst err = getStreamSomehow();\nconst myConsole = new console.Console(out, err);\n\nmyConsole.log('hello world');\n// Prints: hello world, to out\nmyConsole.log('hello %s', 'world');\n// Prints: hello world, to out\nmyConsole.error(new Error('Whoops, something bad happened'));\n// Prints: [Error: Whoops, something bad happened], to err\n\nconst name = 'Will Robinson';\nmyConsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to err\n```","summary":"The `node:console` module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.","examples":[{"language":"js","displayName":null,"code":"console.log('hello world');\n// Prints: hello world, to stdout\nconsole.log('hello %s', 'world');\n// Prints: hello world, to stdout\nconsole.error(new Error('Whoops, something bad happened'));\n// Prints error message and stack trace to stderr:\n//   Error: Whoops, something bad happened\n//     at [eval]:5:15\n//     at Script.runInThisContext (node:vm:132:18)\n//     at Object.runInThisContext (node:vm:309:38)\n//     at node:internal/process/execution:77:19\n//     at [eval]-wrapper:6:22\n//     at evalScript (node:internal/process/execution:76:60)\n//     at node:internal/main/eval_string:23:3\n\nconst name = 'Will Robinson';\nconsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to stderr"},{"language":"js","displayName":null,"code":"const out = getStreamSomehow();\nconst err = getStreamSomehow();\nconst myConsole = new console.Console(out, err);\n\nmyConsole.log('hello world');\n// Prints: hello world, to out\nmyConsole.log('hello %s', 'world');\n// Prints: hello world, to out\nmyConsole.error(new Error('Whoops, something bad happened'));\n// Prints: [Error: Whoops, something bad happened], to err\n\nconst name = 'Will Robinson';\nmyConsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to err"}],"children":[{"kind":"class","id":"class-console","name":"Console","title":"Class: `Console`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/9744","commit":null,"description":"Errors that occur while writing to the underlying streams will now be ignored by default."}],"extends":null,"description":"The `Console` class can be used to create a simple logger with configurable\noutput streams and can be accessed using either `require('node:console').Console`\nor `console.Console` (or their destructured counterparts):\n\n```mjs\nimport { Console } from 'node:console';\n```\n\n```cjs\nconst { Console } = require('node:console');\n```\n\n```js\nconst { Console } = console;\n```","summary":"The `Console` class can be used to create a simple logger with configurable output streams and can be accessed using either `require('node:console').Console` or `console.Console` (or their destructured counterparts):","examples":[{"language":"mjs","displayName":null,"code":"import { Console } from 'node:console';"},{"language":"cjs","displayName":null,"code":"const { Console } = require('node:console');"},{"language":"js","displayName":null,"code":"const { Console } = console;"}],"children":[{"kind":"constructor","id":"new-consolestdout-stderr-ignoreerrors","name":"Console","title":"`new Console(stdout[, stderr][, ignoreErrors])`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"stdout","type":null,"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"stderr","type":null,"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"ignoreErrors","type":null,"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"constructor","id":"new-consoleoptions","name":"Console","title":"`new Console(options)`","scope":"module","overloadOf":"new-consolestdout-stderr-ignoreerrors","stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.10.0"],"prUrl":"https://github.com/nodejs/node/pull/60082","commit":null,"description":"The `inspectOptions` option can be a `Map` from stream to options."},{"versions":["v14.2.0","v12.17.0"],"prUrl":"https://github.com/nodejs/node/pull/32964","commit":null,"description":"The `groupIndentation` option was introduced."},{"versions":["v11.7.0"],"prUrl":"https://github.com/nodejs/node/pull/24978","commit":null,"description":"The `inspectOptions` option is introduced."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/19372","commit":null,"description":"The `Console` constructor now supports an `options` argument, and the `colorMode` option was introduced."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/9744","commit":null,"description":"The `ignoreErrors` option was introduced."}],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"stdout","type":{"text":"stream.Writable","links":[{"name":"stream.Writable","href":"stream.html#class-streamwritable","start":0,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"stderr","type":{"text":"stream.Writable","links":[{"name":"stream.Writable","href":"stream.html#class-streamwritable","start":0,"end":15}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"ignoreErrors","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Ignore errors when writing to the underlying\nstreams.","default":"true","optional":true,"rest":false,"properties":[]},{"name":"colorMode","type":{"text":"boolean | string","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":10,"end":16}]},"description":"Set color support for this `Console` instance.\nSetting to `true` enables coloring while inspecting values. Setting to\n`false` disables coloring while inspecting values. Setting to\n`'auto'` makes color support depend on the value of the `isTTY` property\nand the value returned by `getColorDepth()` on the respective stream. This\noption can not be used, if `inspectOptions.colors` is set as well.","default":"'auto'","optional":true,"rest":false,"properties":[]},{"name":"inspectOptions","type":{"text":"Object | Map","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6},{"name":"Map","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map","start":9,"end":12}]},"description":"Specifies options that are passed along to\n[`util.inspect()`](util.html#utilinspectobject-options). Can be an options object or, if different options\nfor stdout and stderr are desired, a `Map` from stream objects to options.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"groupIndentation","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Set group indentation.","default":"2","optional":true,"rest":false,"properties":[]}]}],"returns":null},"description":"Creates a new `Console` with one or two writable stream instances. `stdout` is a\nwritable stream to print log or info output. `stderr` is used for warning or\nerror output. If `stderr` is not provided, `stdout` is used for `stderr`.\n\n```mjs\nimport { createWriteStream } from 'node:fs';\nimport { Console } from 'node:console';\n// Alternatively\n// const { Console } = console;\n\nconst output = createWriteStream('./stdout.log');\nconst errorOutput = createWriteStream('./stderr.log');\n// Custom simple logger\nconst logger = new Console({ stdout: output, stderr: errorOutput });\n// use it like console\nconst count = 5;\nlogger.log('count: %d', count);\n// In stdout.log: count 5\n```\n\n```cjs\nconst fs = require('node:fs');\nconst { Console } = require('node:console');\n// Alternatively\n// const { Console } = console;\n\nconst output = fs.createWriteStream('./stdout.log');\nconst errorOutput = fs.createWriteStream('./stderr.log');\n// Custom simple logger\nconst logger = new Console({ stdout: output, stderr: errorOutput });\n// use it like console\nconst count = 5;\nlogger.log('count: %d', count);\n// In stdout.log: count 5\n```\n\nThe global `console` is a special `Console` whose output is sent to\n[`process.stdout`](process.html#processstdout) and [`process.stderr`](process.html#processstderr). It is equivalent to calling:\n\n```js\nnew Console({ stdout: process.stdout, stderr: process.stderr });\n```","summary":"Creates a new `Console` with one or two writable stream instances. `stdout` is a writable stream to print log or info output. `stderr` is used for warning or error output. If `stderr` is not provided, `stdout` is used for `stderr`.","examples":[{"language":"mjs","displayName":null,"code":"import { createWriteStream } from 'node:fs';\nimport { Console } from 'node:console';\n// Alternatively\n// const { Console } = console;\n\nconst output = createWriteStream('./stdout.log');\nconst errorOutput = createWriteStream('./stderr.log');\n// Custom simple logger\nconst logger = new Console({ stdout: output, stderr: errorOutput });\n// use it like console\nconst count = 5;\nlogger.log('count: %d', count);\n// In stdout.log: count 5"},{"language":"cjs","displayName":null,"code":"const fs = require('node:fs');\nconst { Console } = require('node:console');\n// Alternatively\n// const { Console } = console;\n\nconst output = fs.createWriteStream('./stdout.log');\nconst errorOutput = fs.createWriteStream('./stderr.log');\n// Custom simple logger\nconst logger = new Console({ stdout: output, stderr: errorOutput });\n// use it like console\nconst count = 5;\nlogger.log('count: %d', count);\n// In stdout.log: count 5"},{"language":"js","displayName":null,"code":"new Console({ stdout: process.stdout, stderr: process.stderr });"}],"children":[]},{"kind":"method","id":"consoleassertvalue-message","name":"assert","title":"`console.assert(value[, ...message])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.101"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/17706","commit":null,"description":"The implementation is now spec compliant and does not throw anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"The value tested for being truthy.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"message","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"All arguments besides `value` are used as error message.","default":null,"optional":true,"rest":true,"properties":[]}],"returns":null},"description":"`console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only\nwrites a message and does not otherwise affect execution. The output always\nstarts with `\"Assertion failed\"`. If provided, `message` is formatted using\n[`util.format()`](util.html#utilformatformat-args).\n\nIf `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.\n\n```js\nconsole.assert(true, 'does nothing');\n\nconsole.assert(false, 'Whoops %s work', 'didn\\'t');\n// Assertion failed: Whoops didn't work\n\nconsole.assert();\n// Assertion failed\n```","summary":"`console.assert()` writes a message if `value` is falsy or omitted. It only writes a message and does not otherwise affect execution. The output always starts with `\"Assertion failed\"`. If provided, `message` is formatted using `util.format()`.","examples":[{"language":"js","displayName":null,"code":"console.assert(true, 'does nothing');\n\nconsole.assert(false, 'Whoops %s work', 'didn\\'t');\n// Assertion failed: Whoops didn't work\n\nconsole.assert();\n// Assertion failed"}],"children":[]},{"kind":"method","id":"consoleclear","name":"clear","title":"`console.clear()`","scope":"module","overloadOf":null,"stability":null,"added":["v8.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"When `stdout` is a TTY, calling `console.clear()` will attempt to clear the\nTTY. When `stdout` is not a TTY, this method does nothing.\n\nThe specific operation of `console.clear()` can vary across operating systems\nand terminal types. For most Linux operating systems, `console.clear()`\noperates similarly to the `clear` shell command. On Windows, `console.clear()`\nwill clear only the output in the current terminal viewport for the Node.js\nbinary.","summary":"When `stdout` is a TTY, calling `console.clear()` will attempt to clear the TTY. When `stdout` is not a TTY, this method does nothing.","examples":[],"children":[]},{"kind":"method","id":"consolecountlabel","name":"count","title":"`console.count([label])`","scope":"module","overloadOf":null,"stability":null,"added":["v8.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"label","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The display label for the counter.","default":"'default'","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Maintains an internal counter specific to `label` and outputs to `stdout` the\nnumber of times `console.count()` has been called with the given `label`.\n\n```console\n> console.count()\ndefault: 1\nundefined\n> console.count('default')\ndefault: 2\nundefined\n> console.count('abc')\nabc: 1\nundefined\n> console.count('xyz')\nxyz: 1\nundefined\n> console.count('abc')\nabc: 2\nundefined\n> console.count()\ndefault: 3\nundefined\n>\n```","summary":"Maintains an internal counter specific to `label` and outputs to `stdout` the number of times `console.count()` has been called with the given `label`.","examples":[{"language":"console","displayName":null,"code":"> console.count()\ndefault: 1\nundefined\n> console.count('default')\ndefault: 2\nundefined\n> console.count('abc')\nabc: 1\nundefined\n> console.count('xyz')\nxyz: 1\nundefined\n> console.count('abc')\nabc: 2\nundefined\n> console.count()\ndefault: 3\nundefined\n>"}],"children":[]},{"kind":"method","id":"consolecountresetlabel","name":"countReset","title":"`console.countReset([label])`","scope":"module","overloadOf":null,"stability":null,"added":["v8.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"label","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The display label for the counter.","default":"'default'","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Resets the internal counter specific to `label`.\n\n```console\n> console.count('abc');\nabc: 1\nundefined\n> console.countReset('abc');\nundefined\n> console.count('abc');\nabc: 1\nundefined\n>\n```","summary":"Resets the internal counter specific to `label`.","examples":[{"language":"console","displayName":null,"code":"> console.count('abc');\nabc: 1\nundefined\n> console.countReset('abc');\nundefined\n> console.count('abc');\nabc: 1\nundefined\n>"}],"children":[]},{"kind":"method","id":"consoledebugdata-args","name":"debug","title":"`console.debug(data[, ...args])`","scope":"module","overloadOf":null,"stability":null,"added":["v8.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.10.0"],"prUrl":"https://github.com/nodejs/node/pull/17033","commit":null,"description":"`console.debug` is now an alias for `console.log`."}],"signature":{"parameters":[{"name":"data","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"args","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":true,"properties":[]}],"returns":null},"description":"The `console.debug()` function is an alias for [`console.log()`](#consolelogdata-args).","summary":"The `console.debug()` function is an alias for `console.log()`.","examples":[],"children":[]},{"kind":"method","id":"consoledirobj-options","name":"dir","title":"`console.dir(obj[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.101"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"obj","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"showHidden","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true` then the object's non-enumerable and symbol\nproperties will be shown too.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"depth","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Tells [`util.inspect()`](util.html#utilinspectobject-options) how many times to recurse while\nformatting the object. This is useful for inspecting large complicated\nobjects. To make it recurse indefinitely, pass `null`.","default":"2","optional":true,"rest":false,"properties":[]},{"name":"colors","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"If `true`, then the output will be styled with ANSI color\ncodes. Colors are customizable;\nsee [customizing `util.inspect()` colors](util.html#customizing-utilinspect-colors).","default":"false","optional":true,"rest":false,"properties":[]}]}],"returns":null},"description":"Uses [`util.inspect()`](util.html#utilinspectobject-options) on `obj` and prints the resulting string to `stdout`.\nThis function bypasses any custom `inspect()` function defined on `obj`.","summary":"Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`. This function bypasses any custom `inspect()` function defined on `obj`.","examples":[],"children":[]},{"kind":"method","id":"consoledirxmldata","name":"dirxml","title":"`console.dirxml(...data)`","scope":"module","overloadOf":null,"stability":null,"added":["v8.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v9.3.0"],"prUrl":"https://github.com/nodejs/node/pull/17152","commit":null,"description":"`console.dirxml` now calls `console.log` for its arguments."}],"signature":{"parameters":[{"name":"data","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":true,"properties":[]}],"returns":null},"description":"This method calls `console.log()` passing it the arguments received.\nThis method does not produce any XML formatting.","summary":"This method calls `console.log()` passing it the arguments received. This method does not produce any XML formatting.","examples":[],"children":[]},{"kind":"method","id":"consoleerrordata-args","name":"error","title":"`console.error([data][, ...args])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.100"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"data","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"args","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":true,"properties":[]}],"returns":null},"description":"Prints to `stderr` with newline. Multiple arguments can be passed, with the\nfirst used as the primary message and all additional used as substitution\nvalues similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](util.html#utilformatformat-args)).\n\n```js\nconst code = 5;\nconsole.error('error #%d', code);\n// Prints: error #5, to stderr\nconsole.error('error', code);\n// Prints: error 5, to stderr\n```\n\nIf formatting elements (e.g. `%d`) are not found in the first string then\n[`util.inspect()`](util.html#utilinspectobject-options) is called on each argument and the resulting string\nvalues are concatenated. See [`util.format()`](util.html#utilformatformat-args) for more information.","summary":"Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to `printf(3)` (the arguments are all passed to `util.format()`).","examples":[{"language":"js","displayName":null,"code":"const code = 5;\nconsole.error('error #%d', code);\n// Prints: error #5, to stderr\nconsole.error('error', code);\n// Prints: error 5, to stderr"}],"children":[]},{"kind":"method","id":"consolegrouplabel","name":"group","title":"`console.group([...label])`","scope":"module","overloadOf":null,"stability":null,"added":["v8.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"label","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":true,"properties":[]}],"returns":null},"description":"Increases indentation of subsequent lines by spaces for `groupIndentation`\nlength.\n\nIf one or more `label`s are provided, those are printed first without the\nadditional indentation.","summary":"Increases indentation of subsequent lines by spaces for `groupIndentation` length.","examples":[],"children":[]},{"kind":"method","id":"consolegroupcollapsed","name":"groupCollapsed","title":"`console.groupCollapsed()`","scope":"module","overloadOf":null,"stability":null,"added":["v8.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"An alias for [`console.group()`](#consolegrouplabel).","summary":"An alias for `console.group()`.","examples":[],"children":[]},{"kind":"method","id":"consolegroupend","name":"groupEnd","title":"`console.groupEnd()`","scope":"module","overloadOf":null,"stability":null,"added":["v8.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Decreases indentation of subsequent lines by spaces for `groupIndentation`\nlength.","summary":"Decreases indentation of subsequent lines by spaces for `groupIndentation` length.","examples":[],"children":[]},{"kind":"method","id":"consoleinfodata-args","name":"info","title":"`console.info([data][, ...args])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.100"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"data","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"args","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":true,"properties":[]}],"returns":null},"description":"The `console.info()` function is an alias for [`console.log()`](#consolelogdata-args).","summary":"The `console.info()` function is an alias for `console.log()`.","examples":[],"children":[]},{"kind":"method","id":"consolelogdata-args","name":"log","title":"`console.log([data][, ...args])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.100"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"data","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"args","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":true,"properties":[]}],"returns":null},"description":"Prints to `stdout` with newline. Multiple arguments can be passed, with the\nfirst used as the primary message and all additional used as substitution\nvalues similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](util.html#utilformatformat-args)).\n\n```js\nconst count = 5;\nconsole.log('count: %d', count);\n// Prints: count: 5, to stdout\nconsole.log('count:', count);\n// Prints: count: 5, to stdout\n```\n\nSee [`util.format()`](util.html#utilformatformat-args) for more information.","summary":"Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to `printf(3)` (the arguments are all passed to `util.format()`).","examples":[{"language":"js","displayName":null,"code":"const count = 5;\nconsole.log('count: %d', count);\n// Prints: count: 5, to stdout\nconsole.log('count:', count);\n// Prints: count: 5, to stdout"}],"children":[]},{"kind":"method","id":"consoletabletabulardata-properties","name":"table","title":"`console.table(tabularData[, properties])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"tabularData","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"properties","type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Alternate properties for constructing the table.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Try to construct a table with the columns of the properties of `tabularData`\n(or use `properties`) and rows of `tabularData` and log it. Falls back to just\nlogging the argument if it can't be parsed as tabular.\n\n```js\n// These can't be parsed as tabular data\nconsole.table(Symbol());\n// Symbol()\n\nconsole.table(undefined);\n// undefined\n\nconsole.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);\n// ┌─────────┬─────┬─────┐\n// │ (index) │ a   │ b   │\n// ├─────────┼─────┼─────┤\n// │ 0       │ 1   │ 'Y' │\n// │ 1       │ 'Z' │ 2   │\n// └─────────┴─────┴─────┘\n\nconsole.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);\n// ┌─────────┬─────┐\n// │ (index) │ a   │\n// ├─────────┼─────┤\n// │ 0       │ 1   │\n// │ 1       │ 'Z' │\n// └─────────┴─────┘\n```","summary":"Try to construct a table with the columns of the properties of `tabularData` (or use `properties`) and rows of `tabularData` and log it. Falls back to just logging the argument if it can't be parsed as tabular.","examples":[{"language":"js","displayName":null,"code":"// These can't be parsed as tabular data\nconsole.table(Symbol());\n// Symbol()\n\nconsole.table(undefined);\n// undefined\n\nconsole.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);\n// ┌─────────┬─────┬─────┐\n// │ (index) │ a   │ b   │\n// ├─────────┼─────┼─────┤\n// │ 0       │ 1   │ 'Y' │\n// │ 1       │ 'Z' │ 2   │\n// └─────────┴─────┴─────┘\n\nconsole.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);\n// ┌─────────┬─────┐\n// │ (index) │ a   │\n// ├─────────┼─────┤\n// │ 0       │ 1   │\n// │ 1       │ 'Z' │\n// └─────────┴─────┘"}],"children":[]},{"kind":"method","id":"consoletimelabel","name":"time","title":"`console.time([label])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.104"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"label","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'default'","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Starts a timer that can be used to compute the duration of an operation. Timers\nare identified by a unique `label`. Use the same `label` when calling\n[`console.timeEnd()`](#consoletimeendlabel) to stop the timer and output the elapsed time in\nsuitable time units to `stdout`. For example, if the elapsed\ntime is 3869ms, `console.timeEnd()` displays \"3.869s\".","summary":"Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique `label`. Use the same `label` when calling `console.timeEnd()` to stop the timer and output the elapsed time in suitable time units to `stdout`. For example, if the elapsed time is 3869ms, `console.timeEnd()` displays \"3.869s\".","examples":[],"children":[]},{"kind":"method","id":"consoletimeendlabel","name":"timeEnd","title":"`console.timeEnd([label])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.104"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v13.0.0"],"prUrl":"https://github.com/nodejs/node/pull/29251","commit":null,"description":"The elapsed time is displayed with a suitable time unit."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5901","commit":null,"description":"This method no longer supports multiple calls that don't map to individual `console.time()` calls; see below for details."}],"signature":{"parameters":[{"name":"label","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'default'","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"Stops a timer that was previously started by calling [`console.time()`](#consoletimelabel) and\nprints the result to `stdout`:\n\n```js\nconsole.time('bunch-of-stuff');\n// Do a bunch of stuff.\nconsole.timeEnd('bunch-of-stuff');\n// Prints: bunch-of-stuff: 225.438ms\n```","summary":"Stops a timer that was previously started by calling `console.time()` and prints the result to `stdout`:","examples":[{"language":"js","displayName":null,"code":"console.time('bunch-of-stuff');\n// Do a bunch of stuff.\nconsole.timeEnd('bunch-of-stuff');\n// Prints: bunch-of-stuff: 225.438ms"}],"children":[]},{"kind":"method","id":"consoletimeloglabel-data","name":"timeLog","title":"`console.timeLog([label][, ...data])`","scope":"module","overloadOf":null,"stability":null,"added":["v10.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"label","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":"'default'","optional":true,"rest":false,"properties":[]},{"name":"data","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":true,"properties":[]}],"returns":null},"description":"For a timer that was previously started by calling [`console.time()`](#consoletimelabel), prints\nthe elapsed time and other `data` arguments to `stdout`:\n\n```js\nconsole.time('process');\nconst value = expensiveProcess1(); // Returns 42\nconsole.timeLog('process', value);\n// Prints \"process: 365.227ms 42\".\ndoExpensiveProcess2(value);\nconsole.timeEnd('process');\n```","summary":"For a timer that was previously started by calling `console.time()`, prints the elapsed time and other `data` arguments to `stdout`:","examples":[{"language":"js","displayName":null,"code":"console.time('process');\nconst value = expensiveProcess1(); // Returns 42\nconsole.timeLog('process', value);\n// Prints \"process: 365.227ms 42\".\ndoExpensiveProcess2(value);\nconsole.timeEnd('process');"}],"children":[]},{"kind":"method","id":"consoletracemessage-args","name":"trace","title":"`console.trace([message][, ...args])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.104"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"message","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"args","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":true,"properties":[]}],"returns":null},"description":"Prints to `stderr` the string `'Trace: '`, followed by the [`util.format()`](util.html#utilformatformat-args)\nformatted message and stack trace to the current position in the code.\n\n```js\nconsole.trace('Show me');\n// Prints: (stack trace will vary based on where trace is called)\n//  Trace: Show me\n//    at repl:2:9\n//    at REPLServer.defaultEval (repl.js:248:27)\n//    at bound (domain.js:287:14)\n//    at REPLServer.runBound [as eval] (domain.js:300:12)\n//    at REPLServer.<anonymous> (repl.js:412:12)\n//    at emitOne (events.js:82:20)\n//    at REPLServer.emit (events.js:169:7)\n//    at REPLServer.Interface._onLine (readline.js:210:10)\n//    at REPLServer.Interface._line (readline.js:549:8)\n//    at REPLServer.Interface._ttyWrite (readline.js:826:14)\n```","summary":"Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` formatted message and stack trace to the current position in the code.","examples":[{"language":"js","displayName":null,"code":"console.trace('Show me');\n// Prints: (stack trace will vary based on where trace is called)\n//  Trace: Show me\n//    at repl:2:9\n//    at REPLServer.defaultEval (repl.js:248:27)\n//    at bound (domain.js:287:14)\n//    at REPLServer.runBound [as eval] (domain.js:300:12)\n//    at REPLServer.<anonymous> (repl.js:412:12)\n//    at emitOne (events.js:82:20)\n//    at REPLServer.emit (events.js:169:7)\n//    at REPLServer.Interface._onLine (readline.js:210:10)\n//    at REPLServer.Interface._line (readline.js:549:8)\n//    at REPLServer.Interface._ttyWrite (readline.js:826:14)"}],"children":[]},{"kind":"method","id":"consolewarndata-args","name":"warn","title":"`console.warn([data][, ...args])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.100"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"data","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"args","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"","default":null,"optional":true,"rest":true,"properties":[]}],"returns":null},"description":"The `console.warn()` function is an alias for [`console.error()`](#consoleerrordata-args).","summary":"The `console.warn()` function is an alias for `console.error()`.","examples":[],"children":[]}]},{"kind":"section","id":"inspector-only-methods","name":"Inspector only methods","title":"Inspector only methods","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The following methods are exposed by the V8 engine in the general API but do\nnot display anything unless used in conjunction with the [inspector](debugger.html)\n(`--inspect` flag).","summary":"The following methods are exposed by the V8 engine in the general API but do not display anything unless used in conjunction with the inspector (`--inspect` flag).","examples":[],"children":[{"kind":"method","id":"consoleprofilelabel","name":"profile","title":"`console.profile([label])`","scope":"module","overloadOf":null,"stability":null,"added":["v8.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"label","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"This method does not display anything unless used in the inspector. The\n`console.profile()` method starts a JavaScript CPU profile with an optional\nlabel until [`console.profileEnd()`](#consoleprofileendlabel) is called. The profile is then added to\nthe **Profile** panel of the inspector.\n\n```js\nconsole.profile('MyLabel');\n// Some code\nconsole.profileEnd('MyLabel');\n// Adds the profile 'MyLabel' to the Profiles panel of the inspector.\n```","summary":"This method does not display anything unless used in the inspector. The `console.profile()` method starts a JavaScript CPU profile with an optional label until `console.profileEnd()` is called. The profile is then added to the **Profile** panel of the inspector.","examples":[{"language":"js","displayName":null,"code":"console.profile('MyLabel');\n// Some code\nconsole.profileEnd('MyLabel');\n// Adds the profile 'MyLabel' to the Profiles panel of the inspector."}],"children":[]},{"kind":"method","id":"consoleprofileendlabel","name":"profileEnd","title":"`console.profileEnd([label])`","scope":"module","overloadOf":null,"stability":null,"added":["v8.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"label","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"This method does not display anything unless used in the inspector. Stops the\ncurrent JavaScript CPU profiling session if one has been started and prints\nthe report to the **Profiles** panel of the inspector. See\n[`console.profile()`](#consoleprofilelabel) for an example.\n\nIf this method is called without a label, the most recently started profile is\nstopped.","summary":"This method does not display anything unless used in the inspector. Stops the current JavaScript CPU profiling session if one has been started and prints the report to the **Profiles** panel of the inspector. See `console.profile()` for an example.","examples":[],"children":[]},{"kind":"method","id":"consoletimestamplabel","name":"timeStamp","title":"`console.timeStamp([label])`","scope":"module","overloadOf":null,"stability":null,"added":["v8.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"label","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[]}],"returns":null},"description":"This method does not display anything unless used in the inspector. The\n`console.timeStamp()` method adds an event with the label `'label'` to the\n**Timeline** panel of the inspector.","summary":"This method does not display anything unless used in the inspector. The `console.timeStamp()` method adds an event with the label `'label'` to the **Timeline** panel of the inspector.","examples":[],"children":[]}]}]}