How do we Use Join() Method in JavaScript

Join Method in Javascript

Learn what join method in javascript with examples.

Join() Method:

It returns a new array by joining the list of elements with the given delimiter/separator.


join(delimeter:*): Array

delimiter: indicates delimiter/ separator to be used while joining.

The join() method does not affect the original array.


var fruits = ["Apple", "Orange", "banana", "Grapes", "Watermelon"];

document.write(fruits, "<br/>"); 


join method in javascript


  1. In the above code, we have created an array of fruits and assigned some values inside the square brackets.
  2. Then we printed the array “fruits” without using the join() method, So the default delimiter is a comma (,) displayed.
  3. If you want to add your desired delimiter symbol between the array list of values. Then you should use the join() method in JS and give value as your delimiters symbol.
  4. Here, we give the “-” hyphen symbol, so the hyphen is displayed between all array values.

Leave a Reply