javascript array to comma separated string
var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(","); //"red,blue,green"
javascript array to comma separated string
var colors = ["red", "blue", "green"];
var colorsCSV = colors.join(","); //"red,blue,green"
javascript join array
var array = ["Joe", "Kevin", "Peter"];
array.join(); // "Joe,Kevin,Peter"
array.join("-"); // "Joe-Kevin-Peter"
array.join(""); // "JoeKevinPeter"
array.join(". "); // "Joe. Kevin. Peter"
.join in javascript
const elements = ['Sun', 'Earth', 'Moon'];
console.log(elements.join());
// output: "Sun,Earth,Moon"
console.log(elements.join(''));
// output: "SunEarthMoon"
console.log(elements.join('-'));
// output: "Sun-Earth-Moon"
js join
//turns array to string
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"
join in array
var a = ['Wind', 'Water', 'Fire'];
a.join(); // 'Wind,Water,Fire'
a.join(', '); // 'Wind, Water, Fire'
a.join(' + '); // 'Wind + Water + Fire'
a.join(''); // 'WindWaterFire'
join array javascript
<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>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us