Console Array data updates after console.log
Reported by
a...@andyandtheweb.com,
Aug 30 2017
|
|||
Issue descriptionUserAgent: 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:
,
Aug 30 2017
,
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).
,
Aug 31 2017
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?
,
Aug 31 2017
> 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).
,
Aug 31 2017
That doesnt work for deep arrays / objects where it previews
(3) [{…}, {…}, {…}]
,
Aug 31 2017
We can't get a copy of the heap every time you console.log...
,
Aug 31 2017
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?
,
Sep 1 2017
Simply use deepCopy |
|||
►
Sign in to add a comment |
|||
Comment 1 by a...@andyandtheweb.com
, Aug 30 2017