P粉5786806752023-08-23 15:48:53
console.log()
Receives a reference to the object, so when the object changes, the value in the console will also change. To avoid this, you can use the following methods:
console.log(JSON.parse(JSON.stringify(c)))
P粉9498488492023-08-23 11:15:47
Pointy's answer provides good information, but is not the correct answer to the question.
The behavior described by the OP is part of a bug that was first reported in March 2010, had a fix for Webkit in August 2012, but as of this writing has not yet been integrated into Google Chrome. The behavior depends on whether the console debug window is opened
or closed when the object literal is passed to console.log().
Excerpt from the original bug report (https://bugs.webkit.org/show_bug.cgi?id=35801):
Response from Chromium developers:
A lot of complaints ensued, eventually leading to a bug fix.
Changelog description of the patch implemented in August 2012 (http://trac.webkit.org/changeset/125174):