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 m
To answer the question - yes, console.log operations are asynchronous so can't be relied upon to print accurate values in the console - especially if you modify the printed object straight after the console.log call (like you are doing).
If you take away the line:
obj.players = {};
then both the differences between the plain console.log and the JSON.stringify dissappear.
Bearing in mind that there is a difference between logging a real object in a developer tools console (console.log(obj) and printing the stringified version of the object (console.log(JSON.stringify(obj))). So the representation of the object will still be different.