If I have an array in JavaScript, say:
var a = [1, 2, 3];
var b = ["Praveen", "Kumar", "Stack", "Overflow"];
If I get the lengths of the above arrays by:
a.length;
b.length;
I get the correct values. i.e.,
a.length; // 3
b.length; // 4
But, if I create another array, where I set my indices like:
c = [];
c[5] = "Five";
c[10] = "Ten";
And then if I query the length, it shows me 11
.
c.length // 11
Is this wrong? Or is this way JavaScript interprets arrays? Please guide.