4 ms·
The problem is that if you log one object multiple times, they all point to the same object. So if between two logs it was modified, it reflects the new status
by Akronymus 3y ago
The problem is that if you log one object multiple times, they all point to the same object.
So if between two logs it was modified, it reflects the new status on the log before as well.
I think you may have been confused and got how it is, vs how it ought to be the wrong way round.
- jay_kyburz 3y agoWow, I never knew this.
- dylan604 3y agoto be honest, my experience with logging objects is so simple, i've never needed to try this live look into the object. my expectation was the log is a snap shot in time, not a live look at the object. an interactive view into the object does sound interesting rather than constant log entries for each step. which is how I would have tried to do something the first time only to be confused by it. TIL.
- jholman 3y agoWhat the parent posts are trying to hint to you is that the default logging behaviour of the console is the live-look model, which is almost never what you wanted with logging. (Though it does have other uses.) To avoid the live-look, you can deep clone, or just stringify.
- jv22222 3y agoThat's just one of the reasons I always say... https://twitter.com/justinvincent/status/1714866433426067573 https://twitter.com/justinvincent/status/1714866433426067573