util.inspect(object[, options])
Return a string representation of object, which is useful for debugging.
An optional options object may be passed that alters certain aspects of the formatted string:
-
showHidden- iftruethen the object's non-enumerable and symbol properties will be shown too. Defaults tofalse. -
depth- tellsinspecthow many times to recurse while formatting the object. This is useful for inspecting large complicated objects. Defaults to2. To make it recurse indefinitely passnull. -
colors- iftrue, then the output will be styled with ANSI color codes. Defaults tofalse. Colors are customizable, see Customizingutil.inspectcolors. -
customInspect- iffalse, then custominspect(depth, opts)functions defined on the objects being inspected won't be called. Defaults totrue.
Example of inspecting all properties of the util object:
const util = require('util');
console.log(util.inspect(util, { showHidden: true, depth: null }));Values may supply their own custom inspect(depth, opts) functions, when called they receive the current depth in the recursive inspection, as well as the options object passed to util.inspect().
Please login to continue.