In Sparse Arrays, elements need not have contiguous indexes.
var arr1 = new Array();
arr1 = "Hello";
arr1 = 432156;
Eventhough we entered only two elements into the array arr1, the Length of the array is 1235 (maximum index + 1 = 1234+1).
Open above document in browser, you can able to see following text.
arr1 length : 1235
For dense array the length of the array is equal to number of elements in the array, where as for sparse arrays the length of the array can be greater than the number of elements in the array.
Previous Next Home