Dina
Dina

Reputation: 1406

Inconsistent data in Chrome Developer Tools

While debugging my Chrome extension I see the following multiple times: enter image description here

On the one hand, the title of the object says Array(2), but on the other hand, when expanding the object, it's evident that the array has only one element.

What's the source of this discrepancy? Is this a bug in the debugger or is there really an extra element in the array (maybe undefined?) that's for some reason is not visible?

Upvotes: 4

Views: 146

Answers (1)

Shudrum
Shudrum

Reputation: 176

This is because an element was removed from the array after the console.log().

Then you have expanded the array.

Just try this on the chrome console:

var myArray = ['value1', 'value2'];
console.log(myArray);
myArray.pop();

Then expand the log of myArray. You will see only one entry, but the already logged line still show 2 entries.

The content of the array is fetched when you expand, they are not duplicated for the log.

Upvotes: 6

Related Questions