javascript implode array code example

Example 1: javascript array to comma separated string

var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(","); //"red,blue,green"

Example 2: can you do a join() in js without the commas

arr.join("")

Example 3: join in array

var a = ['Wind', 'Water', 'Fire'];
a.join();      // 'Wind,Water,Fire'
a.join(', ');  // 'Wind, Water, Fire'
a.join(' + '); // 'Wind + Water + Fire'
a.join('');    // 'WindWaterFire'

Example 4: array implode in javascript

var fruits = ["Banana", "Orange", "Apple", "Mango"];

var energy = fruits.join();

Example 5: javascript implode function

Javascript implode explode functions