If you set array[200] to something, it's not like JavaScript comes along behind you and sets array[0] through array[199]. Arrays are automatically sparse.
So is the problem that if you ask for an uninitialized element, you get undefined back instead of null? Or is there some other issue?
If it's the undefined vs null thing, then just add the nulls after you initialize it, with a loop, instead of having to put them in the big literal blob:
for (var i=0; i<array.length; ++i) {
if (typeof(array[i]) === 'undefined') {
array[i] = null;
}
}
If you want nulls out past what you initialized, replace array.length with whatever your maximum index needs to be (+1, or else change the < to <=).
nulls and you want the array not to have them, but you got to have them.I'm confused! What is it exactly that you want then?!