
Array.shift() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
448
|
ActionScript Language Reference
Array.shift() Method
remove the first element of an array
Flash 5
array.shift()
Returns
The value of the first element of array, which is also deleted.
Description
The shift() method deletes the first element of an array and then moves all the remaining
elements of the array up one position. The affected array’s
length is reduced by 1. Note
that shift() differs from the pop() method, which deletes the last element of an array.
Example
myList = new Array ("a", "b", "c");
myList.shift(); // myList becomes ["b", "c"]
See Also
Array.pop(), Array.splice(), Array.unshift(); “Removing Elements from an Array,” in
Chapter 11
Array.slice() Method
create a new array using a subset of elements from an existing array
Flash 5
array.slice(startIndex, endIndex)
Arguments
startIndex A zero-relative integer specifying the first element of array to add to the new
array. If negative,
startIndex indicates an element number counting back-
ward from the end of
array (–1 is the last element, –2 is the second-to-last
element, etc.).
endIndex An integer specifying the element after the last element of
array to add to the
new array. If negative,
endIndex counts backward from the end of array (–1 is
the last element, –2 is the second-to-last element, etc.). If omitted,
endIndex ...