New issue
Advanced search Search tips

Issue 760776 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Aug 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Console Array data updates after console.log

Reported by a...@andyandtheweb.com, Aug 30 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36

Steps to reproduce the problem:
1. In the console enter: var x = [1,2,3,4];
2. In the console enter: console.log(x);

It should show: ▶ (4) [1,2,3,4]

3. In the console enter: x.shift();
4. In the console log from line 2, click the arrow to open the array. You will now see:

▼ (4) [1,2,3,4[
  0: 2
  1: 3
  2: 4

**This occurs when using console.log on an array inside a .js file from a site as well. The above is just the best way to easily demonstrate it.

What is the expected behavior?
The previous console log should show the array's content prior to the shift() command like so:

▼ (4) [1,2,3,4[
  0: 1
  1: 2
  2: 3
  3: 4

What went wrong?
The contents displayed by the down arrow are not flashed from the moment the array is logged. Therefore it is not possible to see the array in a state prior to an update to the array.

Did this work before? N/A 

Chrome version: 60.0.3112.113  Channel: stable
OS Version: OS X 10.12.5
Flash Version:
 
array bug.png
29.7 KB View Download
Sorry about the typo. It should be ...[1,2,3,4], not ...[1,2,3,4[
Labels: Needs-Triage-M61

Comment 3 by woxxom@gmail.com, Aug 31 2017

Yeah, this historical quirk/feature makes debugging less trivial as we either have to deepCopy the objects (may be slow and requires using a 3rd-party deepCopy implementation) or use JSON.stringify (loses formatting and interactivity).
I noticed the [i] button marks that it is evaluated when you open it. Perhaps an option to automatically evaluate objects & arrays could be offered?
Status: WontFix (was: Unconfirmed)
> Perhaps an option to automatically evaluate objects & arrays could be offered?

That's what is shown in the preview ([1,2,3,4] that you see before you expand the row).
That doesnt work for deep arrays / objects where it previews

(3) [{…}, {…}, {…}]
We can't get a copy of the heap every time you console.log...
I can understand that, but is there some other way to allow me the developer to control this similar to a 'debugger;' call in the JS? Could there be if there isn't one?

Comment 9 by woxxom@gmail.com, Sep 1 2017

Simply use deepCopy

Sign in to add a comment