JavaScript Array join() method

The JavaScript array join() method combines all the elements of an array into a string and return a new string. We can use any type of separators to separate given array elements.

Syntax

The join() method is represented by the following syntax:

Parameter

Separator() - It is optional. It represent the separator used between array elements.

Return

A new string contains the array values with specified separator.

JavaScript Array join() method example

Let's see some examples of join() method.

Example 1

Let's see a simple example of join() method.

Test it Now

Output:

AngularJs,Node.js,JQuery

Example 2

In this example, we will separate the array elements using '-' separator.

Test it Now

Output:

AngularJs-Node.js-JQuery





Latest Courses