![]() ![]() | |
Flash Player 5.
my_array.join([separator])
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.
String.
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.
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 panel:
a_array = new Array("Earth","Moon","Sun")
trace(a_array.join());
// returns Earth, Moon, Sun
trace(a_array.join(" - "));
// returns Earth - Moon - Sun
trace(a_array.join(" + "));
// returns Earth + Moon + Sun
![]() ![]() | |