JavaScript Array join() method
- Previous Page isArray()
- Next Page keys()
- Go Back to the Previous Level JavaScript Array Reference Manual
Definition and usage
join()
The method returns the array as a string.
Elements will be separated by the specified delimiter. The default delimiter is a comma (,).
Note:join()
The method does not change the original array.
Instance
Example 1
Convert array elements to a string:
var fruits = ["Banana", "Orange", "Apple", "Mango"]; var energy = fruits.join();
Example 2
Try using different delimiters:
var fruits = ["Banana", "Orange", "Apple", "Mango"]; var energy = fruits.join(" and ");
Syntax
array.join(separator)
Parameter value
Parameter | Description |
---|---|
separator | Optional. The delimiter to use. If omitted, elements are separated by commas. |
Technical details
Return value: | A string value representing the array values, separated by a specified delimiter. |
---|---|
JavaScript version: | ECMAScript 1 |
Browser support
All browsers fully support join()
Method:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Array
Tutorial:JavaScript Array Const
Tutorial:JavaScript Array Methods
Tutorial:JavaScript Array Sorting
Tutorial:JavaScript Array Iteration
- Previous Page isArray()
- Next Page keys()
- Go Back to the Previous Level JavaScript Array Reference Manual