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.


Browser Support

join() is an ECMAScript1 (ES1) feature.

ES1 (JavaScript 1997) is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.