Array.join()
Availability
Flash Player 5.
Usage
my_array.join([separator:String]) : String
Parameters
A character or string that separates array elements in the returned string. If you omit
separator
this parameter, a comma (,) is used as the default separator.
Returns
A 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
Example
The following example creates an array with three elements: Earth, Moon, and Sun. It then joins
the array three times—first using the default separator (a comma [,] and a space), then using a
dash (-), and then using a plus sign (+).
var a_array:Array = new Array("Earth","Moon","Sun")
trace(a_array.join());
// displays Earth,Moon,Sun
trace(a_array.join(" - "));
// displays Earth - Moon - Sun
trace(a_array.join(" + "));
// displays Earth + Moon + Sun
The following example creates a nested array containing two arrays. The first array has three
elements: Europa, Io, and Callisto. The second array has two elements: Titan and Rhea. It joins
the array using a plus sign (+), but the elements within each nested array remain separated by a
comma (,).
var a_nested_array:Array = new Array(["Europa", "Io", "Callisto"], ["Titan",
"Rhea"]);
trace(a_nested_array.join(" + "));
// returns Europa,Io,Callisto + Titan,Rhea
See Also
String.split()
method.
join()
Array.join()
107
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?