JavaScript Array join() Method
You are Here:
JavaScript Array join() Method
The join()
method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string.
Note: This method will not change the original array.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<script>
var myNumber = [1, 2, 3, 4, 5, 6, 7];
document.write(myNumber.join() +"<br>");
// join array elements with nothing
document.write(myNumber.join("") +"<br>");
// join array elements with underscore
document.write(myNumber.join("_"));
</script>
</body>
</html>
Syntax
Array.join(separator)
Parameter Values
Value | Type | Explanation |
---|---|---|
separator | Optional | Specifies a string to separate each pair of adjacent elements of the array. If separator is not specified, the default value is "-" (Hyphen). |
Return Values
Value | Explanation |
---|---|
string | A new string by concatenating all of the elements in an array separated by commas or a specified separator string. |
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.