JavaScript Array join() Method

Below is the example of the Array join() method.

  • Example:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <script> 
       function func() { 
          var a = [ 1, 2, 3, 4, 5, 6 ]; 
          document.write(a.join('|')); 
       
       func(); 
    < /script> 

    chevron_right

    
    

  • Output:
    1|2|3|4|5|6

The arr.join() method is used to join the elements of an array into a string. The elements of the string will be separated by a specified separator and its default value is a comma(, ).

Syntax:

array.join(separator)

Parameters: This method accept single parameter as mentioned above and described below: