JavaScript tutorial:
join method

ContentsJavaScript Language Reference

Applies to: Array Object

The join method join two or more array objects element together with a specified separator.

Syntax

arrayobj.join(separator)

The separator argument is a String object that is used to separate one element of an array from the next in the resulting String object.

Return String

Returns a String object consisting of all the elements of an array concatenated together.

Example

The join method returns a String object that contains each element converted to a string and concatenated together.

The following example illustrates the use of the join method

a = new Array(1,2,3,4,5);
b = a.join(";");
document.write(b);

To run the code above, paste it into JavaScript Editor, and click the Execute button


See also: Array Object Methods, String Object