Weird behavior with objects & console.log [duplicate]

Examining objects via console.log happens in an asynchronous manner. The console receives a reference to the object synchronously, but does not display the properties of the object until it is expanded (in some cases, depending on the browser and whether you have dev tools open when the log happens). If the object has been modified before examining it in the console, the data shown will have the updated values.

For example, Chrome will show a little i in a box which, when hovered, says:

Object value at left was snapshotted when logged, value below was evaluated just now.

to let you know what you’re looking at.

One trick for logging in these cases is to log the individual values:

console.log(,, obj.baz);

Or JSON encode the object reference:


Leave a Comment