Array.toString( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
Array.toString( ) Method Flash 5

convert an array to a string of comma-separated element values
array.toString()

Returns

A comma-separated list of array's elements, converted to strings.

Description

The toString( ) method creates a string representation of array. The string returned by toString( ) is a list of array elements converted to strings and separated by commas (the same as is returned by the join( ) method when join( ) is invoked without parameters). An array's toString( ) method is invoked automatically whenever the array is used in a string context. Therefore, it is rarely necessary to invoke toString( ) manually. Normally, when we want a precise string representation of an array, we use the join( ) method, which offers more control over the string we're creating.

Example

myList = new Array("a", "b", "c");             // Create an array trace(myList.toString());                      // Displays: "a,b,c" myList = new Array([1, 2, 3], "a", "b", "c");  // Create a nested array trace(myList.toString());                      // Displays: "1,2,3,a,b,c"

See Also

Array.join( )

     



    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