How to use "join()" to create a string from an array using JavaScript?

Q

How to use "join()" to create a string from an array using JavaScript?

✍: Guest

A

"join" concatenates the array elements with a specified seperator between them.

<script type="text/javascript">
var days = ["Sunday","Monday","Tuesday","Wednesday",
   "Thursday","Friday","Saturday"];
document.write("days:"+days.join(","));
</script>

This produces
days:Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday

2011-07-26, 2816👍, 0💬