JavaScript (ES2026) reference · Array Methods

JavaScript Array join() Method

Join all elements into one string, separated by commas or by a separator you choose.

JavaScript (ES2026) Since ES1

Syntax

array.join(separator)

Parameters

ParameterDescription
separator optional Text between elements. Default: ","

Return value

A string.

Examples

Different separatorsTry it yourself
const words = ["red", "green", "blue"];
console.log(words.join(), words.join(" - "), words.join(""));

Output

red,green,blue red - green - blue redgreenblue
null and undefined become emptyTry it yourself
console.log([1, null, undefined, 4].join("-"));

Output

1---4

Version history

VersionChange
JavaScript ES1Added

In other languages