Create Array Elements Method
The Create Array Elements method creates a string of array elements. It returns a string that contains the array elements. A comma or the separatorString argument separates each element.
Format
arrayName.join([separatorString])
The following table describes the arguments for the Create Array Elements method.
Argument | Description |
---|---|
separatorString |
A string of characters that occur between consecutive elements of the array. If you do not use a separatorString argument, then you can use a comma. |
Usage
Commas separate the array elements by default. The following example sets the value that the string variable contains to 3,5,6,3:
var a = new Array(3, 5, 6, 3);
var string = a.join();
To separate the array elements, you can write code that passes another string as an optional argument to the Create Array Elements method.
Example
The following example creates a
string that contains a value of 3*/*5*/*6*/*3
:
var a = new Array(3, 5, 6, 3);
var string = a.join("*/*");