CKTIS / JavaScript
Array.prototype.join: joining elements into a string
join converts elements to text and joins them with a separator, treating holes, null, and undefined as empty pieces.
Version: ECMAScript 2026 draft; example target: Node.js 24.22.2
Syntax
array.join([separator])array.join([separator]) returns one string. The default separator is a comma; a supplied separator is converted to text. Each element is read and converted, except that null, undefined, and a hole contribute an empty piece. A nested array uses its own toString, so an inner comma normally appears.
The method does not mutate its receiver and is generic for array-like objects. An empty array yields an empty string, and one element adds no separator. Getter or conversion failures propagate; a Symbol requiring abstract string conversion can throw TypeError. The example shows empty pieces and an independent outer separator around nested arrays.
Examples
console.log([1, null, , 3].join("|"));
console.log([[1, 2], [3]].join(";"));
console.log(JSON.stringify([].join("-")));Result
1|||3 1,2;3 ""