How do I convert array to string in JavaScript?

To convert an array to a string in JavaScript, you can use the array.toString() method. The toString() method allows you to convert and combine all the elements of an array into a single string value, where a comma will separate the array elements. If the method is called on an empty array (the array's length is zero), then an empty string will be returned in this case. Any array element that is undefined or null will be converted to an empty string. The array.toString() method does not take any parameters. If you need to convert an array to a string and use a separator between elements, you can use the array.join(separator) method. In this example of converting an array to a string in JavaScript, we use the toString() method. Click Execute to run the JavaScript toString Example online and see the result.
Loading...