styling join separator 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: join method javascript
var array = ["Joe", "Kevin", "Peter"];
array.join(); // "Joe,Kevin,Peter"
array.join("-"); // "Joe-Kevin-Peter"
array.join(""); // "JoeKevinPeter"
array.join(". "); // "Joe. Kevin. Peter"