I am using Console.log to identify the array values of a function. While examining the console I see a number of places where Array(0) exists:
In particular, I have created an array of key value pairs (see "x" and "testedElements" (same object) at the bottom of the picture above.)
When I expand "x" out that "Array(0)" sits at the top of an array element... I am unsure what "Array(0) means.. does it signify that this element is an array?
I was actually trying to recreate the structure of "full MENU" at the top of the console picture but I have "Array(0)" displaying in the middle of testedElements/x...
That's how Chrome displays an 0-length array in value summaries in the console. Empty arrays can still contain fields due to the nature of JavaScript.
var obj = {};
obj.array = [];
obj.array.myField = 1;
console.log(obj);
This will log the following in the console:
> {array: Array(0)}
And when I expand it:
{array: Array(0)}
array: Array(0)
myField: 1
length: 0
__proto__: Array(0)
__proto__: Object
This shows that named fields are not items in an array.
If you want an associative array (Array with named indexes), you should use plain JavaScript objects.
var obj = {};
obj.A = 10;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With