User Guide

Array 253
Example
The following code creates the array
myPets_array array containing four elements, and then
removes its last element:
var myPets_array:Array = new Array("cat", "dog", "bird", "fish");
var popped:Object = myPets_array.pop();
trace(popped); // Displays fish.
trace(myPets_array); // Displays cat,dog,bird.
See also
push (Array.push method), shift (Array.shift method), unshift (Array.unshift
method)
push (Array.push method)
public push(value:Object) : Number
Adds one or more elements to the end of an array and returns the new length of the array.
Availability: ActionScript 1.0; Flash Player 5
Parameters
value:Object - One or more values to append to the array.
Returns
Number - An integer representing the length of the new array.
Example
The following example creates the array
myPets_array with two elements, cat and dog. The
second line adds two elements to the array.
Because the
push() method returns the new length of the array, the trace() statement in the
last line sends the new length of
myPets_array (4) to the Output panel.
var myPets_array:Array = new Array("cat", "dog");
var pushed:Number = myPets_array.push("bird", "fish");
trace(pushed); // Displays 4.
See also
pop (Array.pop method), shift (Array.shift method), unshift (Array.unshift
method)