JavaScript – Convert Array of Characters to a String

To convert given array of characters to a string in JavaScript, use Array.join() method.

join() method takes a delimiter string, and joins the elements of the array (array of characters), and returns the resulting string. Since we need no delimiter string, pass an empty string as argument to join() method.

The syntax of the statement to convert an array of characters charArray to a string str is

var str = charArray.join("");

Example

In the following example, we take an array of characters in charArray, join them to a string using Array.join() method, and display the resulting string in pre#output.

index.html

ADVERTISEMENT

Conclusion

In this JavaScript Tutorial, we learned how to convert a given array of characters to a string in JavaScript using Array.join() method, with example program.