A-C > Array.join

Array.join

Syntax

myArray.join();
myArray.join(separator);

Arguments

separator A character or string that separates array elements in the returned string. If you omit this argument, a comma is used as the default separator.

Description

Method; converts the elements in an array to strings, concatenates them, inserts the specified separator between the elements, and returns the resulting string.

Player

Flash 5 or later.

Example

The following example creates an array, with three elements. It then joins the array three times: using the default separator, then a comma and a space, and then a plus sign.

a = new Array("Earth","Moon","Sun")
// assigns "Earth,Moon,Sun" to myVar1
myVar1=a.join(); 
// assigns "Earth, Moon, Sun" to myVar2
myVar2=a.join(", "); 
// assigns "Earth + Moon + Sun" to myVar3
myVar3=a.join(" + ");