JavaScript sparse array by example
JavaScript array is still an object
Only valid natural numeric properties are counted as index
Valid index range: [0,232-1)
If we use invalid index, then JS treats array as normal object, not array nature.
Add element at arbitrary index
Array will expand to fit largest index number.
Force change length
property
Array with holes is called sparse array
Array without holes is called dense array
Sparse array vs dense array
for var
forEach
for in
So avoid use for in
to loop over array, because it includes non-index property also.