javascript convert array to string with commas code example
Example 1: javascript array to comma separated string
var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(",");
Example 2: javascript array to csv string
var colors = ["red", "blue", "green"];
var colorsString = colors.join(",");
Example 3: javascript array to string without commas
arr.join("")
Example 4: javascript array to string without commas
[1, 2, 3].join("");
Example 5: javascript join address to string
var address = "foo";
var city;
var state = "bar";
var zip;
text = [address, city, state, zip].filter(Boolean).join(", ");
console.log(text)
Example 6: javascript array to string with comma
let numbers = [0, 1, 2, 3];
let numbersToString = numbers.toString();
console.log(numbersToString);