Home > Web Front-end > JS Tutorial > body text

Why Does console.log() Display Updated Values for Modified Nested Arrays in Google Chrome?

Susan Sarandon
Release: 2024-10-20 11:43:02
Original
270 people have browsed it

Why Does console.log() Display Updated Values for Modified Nested Arrays in Google Chrome?

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!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!