Reputation: 373
I have an object with deeply nested properties.
Here is the result of console.log(myObject)
in Chrome.
But the result of console.log(myObject.schedules)
is {}
.
When I JSON.stringify the original object the result is {"schedules":{}}
, which I find really confusing. As you see above, its logging a lot more than just that.
Any idea what the problem is?
Upvotes: 2
Views: 590
Reputation: 373
The problem is that my object was being created via an asynch method call. So, at the point I was console.log()
and JSON.stringify()
, the object was not done being created.
Upvotes: 0
Reputation: 1689
You can also use JSON.stringify(object)
, for more details read this.
Upvotes: 1
Reputation: 15501
Do console.dir(myObject)
instead.
console.dir()
displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.
Upvotes: 4