Skip to content

JavaScript array join method | Join the elements of an array into a string

  • by

JavaScript array join method is used to join the elements of an array into a string. You can use specified separators like space or other special characters etc. But the separator default value is a comma (,).

Note: this method will not change the original array.



Parameter Values

Its and optional and default value is comma(, ).

Return Value

A string with all array elements joined. If Array length is 0, the empty string is returned.

Examples of JavaScript array join method

Let’s see the example of how to Convert the elements of an array into a string using a join() function in JS.

<!DOCTYPE html> 
        var alpha = ["A", "B", "C", "D"];
		var n = alpha.join();


JavaScript array join method

Q: How to javascript join two arrays?

Answer: Use concat() method to join two or more arrays. It doesn’t t change the original arrays, but returns a new array, containing the values of the joined arrays.

new_array = array1.concat(array2, array3, ..., arrayX)

Read more and Examples: JavaScript array concat | Method | merge (add) two arrays

Do comment if you have any doubts and suggestions on this tutorial.

Note: The All JS Examples codes are tested on the Safari browser (Version 12.0.2) and Chrome.
OS: macOS 10.14 Mojave
Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *