Reputation: 80
Why are some Javascript object properties not displayed interactively in the debugger?
I have a complex object "albums". If, in the Chrome debugger, I do:
console.dir(albums)
I get an empty object (expanding it shows nothing).
Likewise, if I do
albums
I get nothing. However, suspecting that it does contain elements, if I ask for a specific property, e.g.,
albums["5146219665061590173"]
I get the various properties belonging to this complex object. Likewise, if I do console.log(JSON.stringify(albums)), I get a full definition of all the nested objects belonging to this object.
The semantics here are unclear to me; why do some object properties not show up? (I thought my Javascript program wasn't working when I ran it in the debugger with strategically placed breakpoints, but now I see that the values are there, they just weren't always showing.)
Thanks in advance.
Upvotes: 1
Views: 337
Reputation: 140230
The console fetches the object's state when you expand it to show properties, if the properties have been removed after the console.log/dir
they don't show up.
Try this:
console.dir(JSON.parse(JSON.stringify(albums)));
Upvotes: 2