Joining array elements in a string

suggest change

To join all of an array’s elements into a string, you can use the join method:

console.log(["Hello", " ", "world"].join("")); // "Hello world"
console.log([1, 800, 555, 1234].join("-")); // "1-800-555-1234"

Values that are not strings are converted with ToString. null and undefined become empty strings, not "null" or "undefined". A nested array is joined with commas, not with the separator you passed.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents