Array.join( ) Method | Flash 5 |
convert an array to a string |
An optional string to be placed between elements in the newly created string. Defaults to a comma if not supplied.
A string composed of all the elements of array, converted to strings and separated by delimiter.
The join( ) method returns a string created by combining all the elements of an array, as follows:
Note that elements that are themselves arrays are converted to strings via the toString( ) method, so nested array elements are always delimited by commas, not by the delimiter used in the join( ) invocation.
fruit = new Array("apples","oranges","bananas","grapes","plums"); // Set fruitString to "apples,oranges,bananas,grapes,plums" // (default delimiter is a comma with no following space) fruitString = fruit.join(); // Use ", " as the delimiter to create nicer formatting than toString( ) // and set fruitString to "apples, oranges, bananas, grapes, plums" (with a // space after each comma) fruitString = fruit.join(", ");
Array.toString( ), String.split( ); "The join( ) Method," in Chapter 11