javascript array join by comma code example
Example 1: javascript array to csv string
var colors = ["red", "blue", "green"];
var colorsString = colors.join(","); //"red,blue,green"
Example 2: .join in javascript
const elements = ['Sun', 'Earth', 'Moon'];
console.log(elements.join());
// output: "Sun,Earth,Moon"
console.log(elements.join(''));
// output: "SunEarthMoon"
console.log(elements.join('-'));
// output: "Sun-Earth-Moon"