August 1999
Intermediate to advanced
1488 pages
72h 53m
English
array.length
The length property holds the number of elements in the array. This property is a read/write variable. If the length property is overwritten with a number that is larger than the original number, new elements are added to the end of the array and assigned undefined values. If the length property is overwritten with a number that is smaller than the original number, elements at the end of the array are lost.
Listing 6.50 creates an array of coins. The number of coins in the array is then reduced from 4 to 3 by modifying the length property so the array contains only three elements. Because the quarter was the ...
Read now
Unlock full access