For the nested Object or Array
var obj = {
foo:
{
foo:
{
foo:
{
foo:
{
foo:
{
foo: 'foo'
}
}
}
}
}
};
console.log(obj);
util.debug(obj);
util.debug(util.inspect(obj));
The console.log
or util.debug
+ util.inspect
{ foo: { foo: { foo: [Object] } } }
DEBUG: [object Object]
DEBUG: { foo: { foo: { foo: [Object] } } }
Under a certain depth, it shows just [Object]
with no further detail.
This is always annoying on debugging since I can't investigate the actual value.
Why does node
(or V8) implements like this? and Is there any work-around?
Thanks.
EDIT: I received a suggestion
console.log(JSON.stringify(obj));
The result
{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":"foo"}}}}}}
It sort of works, but obviously the whole is stringify
ed, and probably I couldn't do this for all object output on debugging. Not generic method.
EDIT2:
solution:
console.log(util.inspect(obj,{ depth: null }));
output:
{ foo: { foo: { foo: { foo: { foo: { foo: 'foo' } } } } } }
cool. This is what I want!