join Method

Top  Previous  Next

Converts array elements to strings and concatenates them.

Syntax

array.join([separator])

Arguments

separatorAn optional string to be inserted between each array element. If omitted, a comma is used.

Return Value

A string consisting of each element of array converted to a string and then concatenated, with separator inserted between each element.

Remarks

When an array is implicitly converted to a string, it is equivalent to using join with no arguments.

Examples

var ary, res;

ary = Array(1, true, "test");

res = ary.join()// returns "1,true,test"
res = ary.join("; ")// returns "1; true; test"