Table of Contents

Array.unshift( ) Method Flash 5

add one or more elements to the beginning of an array
array.unshift(value1, value2,...valuen)

Arguments

value1, ...valuen

A list of one or more element values to be added to the beginning of array.

Returns

The new length of array.

Description

The unshift( ) method adds a series of elements to the beginning of an array. Elements are added in the order specified. To add elements at the end of an array, use push( ).

Example

myList = new Array (5, 6);
myList.unshift(4);         // myList becomes [4, 5, 6]
myList.unshift(7, 1);      // myList becomes [7, 1, 4, 5, 6]

See Also

Array.push( ), Array.shift( ); "Adding Elements to an Array," in Chapter 11


Table of Contents