Google Chrome's console.log Inconsistency with Objects and Arrays
A peculiar behavior has been identified with Google Chrome's console.log() function when dealing with nested arrays. If an array is logged with console.log(), and one of its inner values is modified subsequently, console.log() continues to display the updated value, rather than the values present at the time of logging.
This behavior seems to be spezifisch für Google Chrome and does not occur in Firefox. Stepping through the code line-by-line with the Chrome debugger, however, yields the correct values for console.log().
Further investigation revealed that this issue has been reported as a bug in Webkit, which includes Google Chrome. The bug description details that console.log() of an object with mutable properties displays updated values upon expansion, even though its state has changed since logging.
A fix implemented in Webkit in 2012 introduced lazy reading of object properties upon console expansion, resolving this issue. However, this fix does not appear to have been integrated into Google Chrome to date.
The above is the detailed content of Why Does console.log() Display Updated Values for Modified Nested Arrays in Google Chrome?. For more information, please follow other related articles on the PHP Chinese website!