For the nested Object or Array
var obj = {
foo:
{
foo:
{
foo:
{
foo:
{
foo:
{
foo: \'
Use JSON.stringify
:
var obj = {
foo:
{
foo:
{
foo:
{
foo:
{
foo:
{
foo: 'foo'
}
}
}
}
}
};
console.log(JSON.stringify(obj));
Result:
{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":"foo"}}}}}}
util.inspect()
takes a second options
argument, where you can specify depth
. The default is 2.
http://nodejs.org/api/util.html#util_util_inspect_object_options
So:
util = require('util');
var obj = { foo: { foo: { foo: { foo: { foo: { foo: 'foo' } } } } } };
console.log(util.inspect(obj, {depth:12}));
... yields:
{ foo: { foo: { foo: { foo: { foo: { foo: 'foo' } } } } } }