What you call a βholeβ is not an exact hole:
var a = [,,,,,,,,,,]; a.length; // 10 var n, k; n=0; for (k in a){if (a.hasOwnProperty(k)){++n;}else{break;}}; n; // 10 : a has 10 own properties, all SET to undefined
Now remove all properties and recount
while (n--) delete a[n]; for (k in a){if (a.hasOwnProperty(k)){++n;}else{break;}}; n;
To get an array with holes, you can either delete the properties manually, or start with Array (N) and populate some indexes with values, or use push / splice, but not the methods that return the array. For instance:
Array(2).concat([void(0)]).concat(Array(3)).concat([3]).concat(Array(2)).concat([4]);
reproduces exactly your original array (it has a length of 10 and 10 of its own properties), although the first term (Array (2)) does not.
EDIT . The above version has been tested in ExtendScript and is not true in recent browsers (see comments). Tested subsequently in Firefox and [,,,] really does not have its own property ...
source share