Looking for javascript Answers? Try Ask4KnowledgeBase
Looking for javascript Keywords? Try Ask4Keywords

JavaScript Joining array elements in a string


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.