本文實例講述了JavaScript通過join函數連接數組裡所有元素的方法。分享給大家供大家參考。具體實現方法如下:
<script type="text/javascript"> var days = ["Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"]; document.write("days:"+days.join(",")); </script>
輸出結果如下:
days:Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
希望本文所述對大家的javascript程序設計有所幫助。