How do I join array elements into a string in JavaScript?

To join all array elements in a string in JavaScript, you can use the array.join(separator) method. The join() method takes an array as input and a delimiter as a parameter and returns a string where all array elements are joined into a string using the specified delimiter. By default, array elements are concatenated using a comma "," as a delimiter. The join() method does not modify the original array. If the method is called on an empty array (the length of the array is zero), then an empty string will be returned; any array element that has the value "undefined" or "null" will be converted to the empty string. In this JavaScript Join Array Elements into a String Example, we use the join() method to join all array elements in a string. Click Execute to run the JavaScript Array Join Example online and see the result.
Loading...