If I have an array having object as values at the indices like:
var a = [];
a[21] = {};
a[90] = {};
a[13] = {};
alert(a.length); // outputs 91
Because that's the behavior of Array.length as described in the ECMAScript spec.
The length property of this Array object is a data property whose value is always numerically greater than the name of every deletable property whose name is an array index.
So Array.length is always the last item's index + 1.