Search code examples
javascriptreferencefirebugfirefox-developer-tools

Firefox dev tools + Chrome debugger consoles buggy display of javascript object references


I'm experiencing some unusual behavior in Firefox Dev Tools. After filtering some elements out of an object with lodash, the console is displaying a reference to the previous unfiltered version of the object, but only on the right side pane.

debug bug

On the left, it shows 2 elements, which is the result I expected. On the right it shows the original unfiltered 17 elements. I've actually experienced this before on rare occasions with Firebug before I was forced to switch to Dev Tools with the recent discontinuation of FB.

If nobody else has experienced this, I could attempt to distill it to a minimal case example, but I'd prefer to just work around it, if it's a known bug.

Leaning toward believing my object is actually filtered as indicated on the left but this is a bit unnerving.

Updates:

Using Firefox 51 Linux

Chrome is actually doing the same thing. It shows array[2] with 17 elements:

chrome debugger


Solution

  • When you inspect an array its current value is displayed, i.e. the value at the time you click the logged variable. This value may differ to the one logged to the console.

    The Chrome DevTools show a little Info icon shown besides an expanded array variable icon besides the array explaining this on hover.

    Chrome DevTools showing expanded array variable and tooltip explaining why the item count differs

    This means, at the time the variable is logged it indeed had only two items in it, but at the time you clicked it, it was obviously unfiltered again.