Examples of sparse array:
// first
let array = new Array(3);
// second
let array = [1,,3];
// third
let array = [1, 2, 3]; // not sparse
delete array[1]; // now it is
// fourth
let array = [1,2 3]; // not sparse
array[1000] = 'foo'; // now it is
Does setting an existing value to undefined or null also make it sparse?
I have an array of objects and I need to express empty slot somehow without making it into sparse because it's then flagged as sparse in modern browser engines and lookup speed is about the same as object key lookup - it needs to walk the prototype chain (a lot slower than index lookup).
nullandundefinedare values in JavaScript, so assigning those values to entries does not make the array sparse.[1,,3], there is no element at index 1, though stringified versions may represent it as undefined, null or empty.nullorundefined, doesn't the engine checkArrayandObjectprototypes, just in case?