array of string to string javascript code example

Example 1: javascript array to comma separated string

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

Example 2: js array to string

var myArray = ['no','u'];
var myString = myArray.toString();

Example 3: javascript join list of string

// array.join(separator)

var myArray ['foo', 'bar', 'baz'];
myarray.join(':');
// foo:bar:baz

Example 4: array to string javascript

<array>.join(<splitting character(s)>);

Example 5: 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'

Tags:

Html Example