A-C > Array.join |
Array.join
array.join, join
Availability
Flash Player 5.
Usage
myArray.join([separator])
Parameters
separator A character or string that separates array elements in the returned string. If you omit this parameter, a comma is used as the default separator.
Returns
String.
Description
Method; converts the elements in an array to strings, inserts the specified separator between the elements, concatenates them, and returns the resulting string. A nested array is always separated by a comma, not by the separator passed to the join method.
Example
The following example creates an array with three elements: Earth, Moon, and Sun. It then joins the array three timesfirst using the default separator (a comma and a space), then using a dash, and then using a plus sign (+)and displays them in the Output window:
a = new Array("Earth","Moon","Sun")
trace(a.join());
// returns Earth, Moon, Sun
trace(a.join(" - "));
// returns Earth - Moon - Sun
trace(a.join(" + "));
// returns Earth + Moon + Sun