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
| Parameter | Description |
|---|---|
separator optional |
Text between elements. Default: "," |
Return value
A string.
Examples
const words = ["red", "green", "blue"];
console.log(words.join(), words.join(" - "), words.join(""));
Output
red,green,blue red - green - blue redgreenblue
console.log([1, null, undefined, 4].join("-"));
Output
1---4
Version history
| Version | Change |
|---|---|
| JavaScript ES1 | Added |
In other languages
str.join()· Python
Related
array.toString()· Return a string of the array's elements separated by commas. Called automatically when an array is used as text.array.concat()· Return a new array that joins this array with other arrays or values. The original arrays are not changed.- JavaScript Arrays · tutorial
- JavaScript Strings · tutorial