Array.unshift( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
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

     



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net