Joining array elements in a string
suggest changeTo 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents