join() Function is used to join all the elements of the Array into a String.
Let us say, we have a Array that contains four names, Mohan, Kriti, Philip and Salim. And we want to convert the Array elements into a String.
<html>
<body>
<script>
var x = ["Mohan", "Kriti", "Philip", "Salim"]
var y = x.join()
document.write(y)
</script>
</body>
</html>
So, we have an Array that has 4 names.
-Function1.png)
So, all we have done is, used the join() method to convert the elements of the array into a string.
var y = x.join()
-Function2.png)
Next, let us say we want to convert the array elements into a String. But we don't want the names separated by comma ','.
Rather, we want the names separated by @.
<html>
<body>
<script>
var x = ["Mohan", "Kriti", "Philip", "Salim"]
var y = x.join("@")
document.write(y)
</script>
</body>
</html>
So, we have an Array that has 4 names.
-Function3.png)
So, all we have done is, used the join() method to convert the elements of the array into a string.
var y = x.join("@")-Function4.png)