Which method joins all array elements into a string?

The story behind the answer

The JavaScript `join()` method combines all array elements into a string, placing a chosen separator between them.

For example, `["Ada", "Grace", "Lin"].join(" - ")` produces `"Ada - Grace - Lin"`. If no separator is supplied, JavaScript uses a comma, so `[1, 2, 3].join()` returns `"1,2,3"`. The method returns a new string and does not change the original array.

Array elements are converted to strings during the operation. `null` and `undefined` elements contribute empty fields, which means `["a", null, "b"].join("|")` becomes `"a||b"`. Nested arrays are converted through their own string representation, a detail that can surprise developers working with multidimensional data.

A frequent mix-up is `split()`, which goes in the opposite direction: it breaks a string into an array. `concat()` combines arrays or values into another array, while `toString()` can also stringify an array but always uses comma separation and offers no custom delimiter. For readable output, `join()` is the purpose-built choice.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: