Array.join() Join into a string
Last updated: 2026-09-09
Array.join() Join into a string
join concatenates all elements into a string with a separator; undefined and null become empty strings. The original is untouched.
| Category | Arrays |
|---|---|
| ES version | ES1 (1997) |
📝 Syntax
array.join(separator);
⚙️ Parameters
| separator | Optional. Glue between elements, default ','; pass '' to concatenate directly. |
|---|
Returns:The joined string.
Mutates the original:No (returns a new value)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
apple,banana,orange
apple、banana、orange
applebananaorange
apple + banana + orange
user/docs/2026
💡 Tip join and split are inverses — str.split(',').join('-') swaps separators.
ℹ️ info undefined and null elements become empty strings; nested arrays are flattened into the string.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| Array.join() | ✓ v1 | ✓ v12 | ✓ v1.5 | ✓ v3 | ✓ v10.5 |
| Supported by all modern browsers | |||||
🏷️ Related Array Methods
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
QWhat if the separator is omitted?
AIt defaults to a comma — the same reason console.log shows commas when printing arrays.
QHow are undefined and null joined?
ABoth become empty strings: [1, undefined, 2].join('-') gives '1--2'.
Qjoin vs toString?
AtoString always uses commas; join takes a custom separator. Implicit conversion calls toString.