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

Author Topic: How to use "join()" to create a string from an array using JavaScript?  (Read 509 times)

Offline chinmay.sahooTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 159
  • Karma: 0
    • Hot Shaper
"join" concatenates the array elements with a specified seperator between them.


Quote
<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


 

Related Topics