JOIN - Join Array Elements With Separator in JavaScript

JOIN functions joins the array elements, separated by "Separator" and returns the output in the String format.
Syntax
Array.Join(Separator);


Example 1 : Joins array element using hyphen as separator
 <script type="text/javascript">
    fruit = new Array("A","B","C");
    aString = fruit.join("-");  
    document.write("The fruit array contains: ",aString);
 </script>

output
---------
A-B-C

Example 2 : Produce CSV (Comma Separated) Output

 <script type="text/javascript">
    fruit = new Array("John","Tom","Harry");
    aString = fruit.join(",");  
    document.write("Nominees are : ",aString);
 </script>

output
---------
John,Tom,Harry