array to string js code example
Example 1: join last element of array javascript with different value
['tom', 'dick', 'harry'].join(', ').replace(/, ([^,]*)$/, ' and $1')
> "tom, dick and harry"
Example 2: javascript array to csv string
var colors = ["red", "blue", "green"];
var colorsString = colors.join(",");
Example 3: js array to string
var myArray = ['no','u'];
var myString = myArray.toString();
Example 4: .join javascript
const elements = ['Fire', 'Air', 'Water'];
console.log(elements.join());
console.log(elements.join(''));
console.log(elements.join('-'));
Example 5: javascript convert in a string the items of an array
const arr = [1, 2, 'a', '1a'];
const str = arr.toString();
console.log(str);
Example 6: array to string js
array.join("").toString()