Home >>JavaScript Array Reference >JavaScript Array join() Method

JavaScript Array join() Method

JavaScript Array join() Method

JavaScript array join() method is an inbuilt function which returns the array as a string and joins all the elements of an array into a string and return a new string. By using a specified separator, you can separate the given array elements and its default separator is comma (,).

Syntax:
array.join(separator)

Parameter Values

Parameter Description
separator It is Optional. The separator to be used and represent the separator used between array elements

Browser Support

Method Chrome Edge Firefox Safari Opera
join() 1.0 5.5 1.0 Yes Yes
Here is an Example of Array join() Method:
<html>
<body>
<button onclick="myarrJoin()">Click me</button>
<p id="join"></p>
<script>
function myarrJoin() 
{
  var col = ["Red", "Blue", "Orange", "Green"];
  var z = document.getElementById("join");
  z.innerHTML = col.join();
}
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
<script>
var arr=["HTML","CSS","JQuery"]
var result=arr.join('+')
document.write(result);
</script>
</body>
</html>
Output:

No Sidebar ads