javascript array object to string code example
Example 1: convert array object to string javascript
var ar = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
console.log( ar.join('') ); // abcdefg
console.log( ar.join(' : ') ); // a : b : c : d : e : f : g
console.log( ar.join('-') ); // a-b-c-d-e-f-g
console.log( ar.join('|') ); // a|b|c|d|e|f|g
Example 2: js array with objects to string
var array = new Array(); //new Array not necessary
var string;
array[0] = {key: value};
array[1] = {key1: value1};
string = JSON.stringify(array);
/*
string should look like
[{"key":"value"},{"key1":"value1"}]
*/