I have reason to believe console.log
and JSON.stringify
can produce inconsistent views of the same object even if it was created in a straightforward manner (see notes).
Situation
In both Google Chrome developer tools and Firebug, I had an object obj
which console.log
printed out as { players: {0: ...}, ...}
, while JSON.stringify
reported { players: {}, ...}
. obj.players
was {}
under both functions, so it seems that console.log
is the culprit. Could it be asynchronous/non-deterministic in some way?
Additional notes
I'm afraid I won't be able to provide much more context, since the code is lengthy and for a client, but I can try if there is something that could help get to the bottom this. For the moment, I am forced to stay away from console.log
for inspection.
It might be useful to know that the object is formed merely from an object literal by setting properties by hand, e.g., obj.players = {}; obj.players[0] = ...
.
Code
A sample of what I mean can be observed at http://jsfiddle.net/9dcJP/.