Log objects to console
TL;DR: expanded objects in the console shows state at current time, not when logged.
So, what you see might not be what you got.
What I mean... #
When writing object to the console using console.log
the objects are contracted:
When the number of properties is too long, the contracted object is not complete (see the three dots ...
)
You can expand an object in the console to see it:
But you can also change the object values (mutate the object, in FP jargon):
And then expand 💥:
As you can see, even if I logged the object before the mutation, when I expand, it shows the current (mutated) state. However the contracted version stays always the same.
When it matters... #
Always... but bear in mind that browser Event properties, for example, are mutated during the dispatch phase.