join()

功能

將陣列轉變為字串,並且選擇連結符。

範例

const arr=["moko", "dog", "swimming"];

const str1=arr.join(",");//用逗號連接
console.log(str1);//"moko,dog,swimming"

const str2=arr.join("");//不要連結
console.log(str2);//"mokodogswimming"