JavaScript Array join()
Example
Convert the elements of an array into a string:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.join() // Returns "Banana,Orange,Apple,Mango"
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The join() method returns an array as a string.
The elements will be separated by a specified separator. The default separator is comma (,).
join() does not change the original array.
Browser Support
join() is fully supported in all browsers:
| Chrome | IE | Edge | Firefox | Safari | Opera |
| Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
array.join(separator)
Parameter Values
| Parameter | Description |
|---|---|
| separator | Optional. The separator to be used. If omitted, the elements are separated with a comma |
Technical Details
| Return Value: | A String, representing the array values, separated by the specified separator |
|---|---|
| JavaScript Version: | ECMAScript 1 |
More Examples
Example
Try using a different separator:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.join(" and ");
Try it Yourself »

