When debugging using console.log()
, how can I get the full object?
const myObject = {
"a":"a",
"b":{
"c":"c",
"d":{
"e":"e",
"f":{
"g":"g",
"h":{
"i":"i"
}
}
}
}
};
console.log(myObject);
Outputs:
{ a: 'a', b: { c: 'c', d: { e: 'e', f: [Object] } } }
But I want to also see the content of property f
.
You need to use util.inspect()
:
const util = require('util')
console.log(util.inspect(myObject, {showHidden: false, depth: null}))
// alternative shortcut
console.log(util.inspect(myObject, false, null, true /* enable colors */))
Outputs
{ a: 'a', b: { c: 'c', d: { e: 'e', f: { g: 'g', h: { i: 'i' } } } } }
See util.inspect()
docs.