Name
Array.push( ) Method — add one or more elements to the end of an array
Availability
Flash 5
Synopsis
array.push(value1, value2,...valuen)
Arguments
- value1,...value
n
A list of one or more values to be added to the end of
array
.
Returns
The new length
of array
.
Description
The push( )
method appends a list of values to
the end of an array as new elements. Elements are added in the order
provided. It differs from concat( )
in that
push( )
modifies the original array, whereas
concat( )
creates a new array. It differs from
unshift( )
in that it adds elements at the end
of an array, not the beginning.
Example
myList = new Array (5, 6); myList.push(7); // myList is now [5, 6, 7] myList.push(10, 8, 9); // myList is now [5, 6, 7, 10, 8, 9]
See Also
Array.concat( )
, Array.pop(
)
, Array.unshift( )
; “Adding
Elements to an Array” in Chapter 11
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.