JavaScript Array join() method
returns a new string by concatenating all of the elements in the array, separated by commas or a specified separator string

join() method returns a new string by concatenating all of the elements in the array, separated by commas or a specified separator string.

join() method returns an array as a string.

syntax

join(separator)

separator (optional). A string to separate each pair of adjacent elements of the array.

join() method does not change the original array.

Any separator can be specified. The default is a comma ,

If the array has only one item, then that item will be returned without using the separator.

If the array is empty [] an empty string '' is returned.

undefined or null elements have an empty string '' representation instead of the string 'null' or 'undefined'

syntax 1 description
return myArray as a string with default comma separator to separate each pair of adjacent elements
myArray.join()
syntax 2 description
return myArray as a string using specified separator string to separate each pair of adjacent elements
myArray.join(separator)