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"

As you can see in the second line, items that are not strings will be converted first.

Feedback about page:

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



Table Of Contents