.join() javascript string code example
Example 1: join javascript array
const cities = ['London', 'Paris', 'Tokyo'];
const joinedCities = cities.join('-');
console.log(joinedCities); // London-Paris-Tokyo
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"