console.dir()

Displays an interactive list of the properties of an object.

Since ES5 Spec ↗

Syntax

console.dir(object, options)

Returns

undefined — Returns `undefined`.

Examples

console.dir({ a: 1, nested: { b: 2 } });
Output
{ a: 1, nested: { b: 2 } }
console.dir([1, 2, 3], { depth: null });
Output
[ 1, 2, 3 ]

Notes

- In browsers, shows a navigable property tree rather than DOM markup (unlike `console.log` for DOM nodes). - In Node.js, accepts options like `depth` and `colors`.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 8
safari 4
edge 12
node 0.10

See also