August 1999
Intermediate to advanced
1488 pages
72h 53m
English
array.shift()
The shift() method deletes and returns the first element of the array. Once deleted, all the remaining elements are shifted down one spot, so the first position is filled by the element that was previously in the second position. Table 6.13 shows the return value associated with this method.
| Type | Item | Description |
|---|---|---|
| Returns | The first element of the array, before the elements are shifted, is returned from the method. |
Listing 6.55 creates an array representing people waiting for a table at a restaurant. The shift() method pulls the first name off the list and shifts all the other names up ...
Read now
Unlock full access