English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The JavaScript array join() method connects all elements in an array into a single string and returns the string.
The returned elements will be separated by the specified separator. The default separator is a comma (,).
array.join(separator)
var alpha = ['A''B''C''D''E']; var str = alpha.join();Test and see‹/›
The numbers in the table specify the first browser version that fully supports the join() method:
Method | |||||
join() | 1 | 1 | Is | Is | 5.5 |
Parameter | Description |
---|---|
separator | Specify a string to separate each element of the array. If omitted, array elements are separated by commas |
Return Value: | A string containing all array elements |
---|---|
JavaScript Version: | ECMAScript 1 |
The following example creates an array containing three elements and then concatenates it five times:
var fruits = ["Banana", "Apple", "Mango"]; fruits.join(""); // BananaAppleMango fruits.join(" "); // Banana Apple Mango fruits.join(" + ); // Banana + Apple + Mango fruits.join(" / ); // Banana / Apple / Mango fruits.join(" © "); // Banana © Apple © MangoTest and see‹/›