本文實例講述了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程式設計有所幫助。