Check out example codes for "join array javascript". It will help you in understanding the concepts better.

Code Example 1

var array = ["Joe", "Kevin", "Peter"];
array.join(); // "Joe,Kevin,Peter"
array.join("-"); // "Joe-Kevin-Peter"
array.join(""); // "JoeKevinPeter"
array.join(". "); // "Joe. Kevin. Peter"

Code Example 2

const elements = ['Fire', 'Air', 'Water'];

console.log(elements.join());
// expected output: "Fire,Air,Water"

console.log(elements.join(''));
// expected output: "FireAirWater"

console.log(elements.join('-'));
// expected output: "Fire-Air-Water"

Code Example 3

<html>
  <select multiple class="select-colors">
    <option>blue</option>
    <option>green</option>
  </select>
</html>  

<script>
  var myColorSelect = $(".select-colors").val().join();
  
 console.log(myColorSelect);
</script>

Code Example 4

<html>
  <select multiple class="select-colors">
    <option>blue</option>
    <option>green</option>
  </select>
</html>  

<script>
  var myColorSelect = $(".select-colors").val().join();
  
 console.log(myColorSelect);
</script>

Code Example 5

const winners = ["George", "Tim", "John"];
const orderedList = winners.map((w, i) => `${i + 1}. ${w}`);

console.log(order.join("\n"));
// expected output:
// 1. George
// 2. Tim
// 3. John

Code Example 6

Javascript implode explode functions

Learn ReactJs, React Native from akashmittal.com