join ExamplesΒΆ

The general syntax for this method is:

arrayName.join('connector')

join combines all the elements of an array into a string. The connector determines the string that "glues" the array elements together.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
let arr = [1, 2, 3, 4];
let words = ['hello', 'world', '!'];
let newString = '';

newString = arr.join("+");
console.log(newString);

newString = words.join("");
console.log(newString);

newString = words.join("_");
console.log(newString);

Output

1+2+3+4
helloworld!
hello_world_!