JavaScript Array join()
Examples
const fruits = ["Banana", "Orange", "Apple", "Mango"];
let text = fruits.join();
Try it Yourself »
Another separator:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
let text = fruits.join(" and ");
Try it Yourself »
Description
The join()
method returns an array as a string.
The join()
method does not change the original array.
Any separator can be specified. The default is comma (,).
Syntax
array.join(separator)
Parameters
Parameter | Description |
separator | Optional. The separator to be used. Default is a comma. |
Return Value
Type | Description |
A string. | The array values, separated by the specified separator. |
Array Tutorials:
Browser Support
join()
is an ECMAScript1 (JavaScriopt 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |