A-C > Array.join

 

Array.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

Nothing.

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. It then joins the array three times—using the default separator, a comma and a space, and 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