The join() method joins the elements of an array into a string, and returns the string.
The join() method joins the elements of an array into a string, and returns the string.
The elements will be separated by a specified separator which is default to comma (,).
array.join(separator)
Parameter | Require | Description |
---|---|---|
separator | Optional. | The separator to be used. If omitted, the elements are separated with a comma |
A String, representing the array values, separated by the specified separator
Join the elements of an array into a string:
var myArray = ["XML", "Json", "Database", "Mango"]; console.log(myArray.join());/* ww w. j a va 2 s . c o m*/ //Try using a different separator: var myArray = ["XML", "Json", "Database", "Mango"]; console.log(myArray.join(" and "));