Array join(): combine values into text
Quick answer
Join creates a string from array values separated by a chosen delimiter. It does not change the original array.
How it works
items.join(separator) uses a comma when the separator is omitted or undefined. Values are converted to text; null, undefined and missing positions contribute empty fields. An empty array yields an empty string.
const words = ["learn", "write", "test"];console.log(words.join(" / "));Expected output in Node.js:
learn / write / testThe separator appears only between values.
const a = ["A", null, "C"];console.log(a.join("-"), a.length);Expected output in Node.js:
A--C 3Null contributes an empty field; the array still has three positions.
Common mistakes
Join is not JSON serialization and does not escape separator characters in values. Use a proper format when data must round-trip.
Practice
Join names with a comma-space and then with an empty separator.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Array join(): combine values into text — Knowledge Check
Apply the taught concept and reason about the result.
What does ["a","b"].join("-") produce?
What separator is used by join() without an argument?
What does ["A",null,"C"].join("-") return?
What does [].join("/") return?
Does join modify the original array?