紀錄工作經驗、相關知識,解決技術相關問題。

Javascript

Javascript join() 陣列轉字串 / Array to String

join() 陣列轉字串

Javascript 中的 Join() 方法,是將陣列中的值,合併成字串,陣列間值與值組合時,連接符號預設以”,”相連,也允許自訂連接符號。

const a = ['js', 'join','test']

console.log(a.join())
// expected output: "js,join,test"

console.log(a.join(', '))
// expected output: "js, join, test"

console.log(a.join(''))
// expected output: "jsjointest"

console.log(a.join('-'))
// expected output: "js-join-test"

console.log(a.join(' '))
// expected output: "js join test"

console.log(a.join('___'))
// expected output: "js___join___test"

Join() 相容性

相容性請參照 MDN Join() 瀏覽器相容性

8 留言

  1. After reading your article, it reminded me of some things about gate io that I studied before. The content is similar to yours, but your thinking is very special, which gave me a different idea. Thank you. But I still have some questions I want to ask you, I will always pay attention. Thanks.

  2. I am an investor of gate io, I have consulted a lot of information, I hope to upgrade my investment strategy with a new model. Your article creation ideas have given me a lot of inspiration, but I still have some doubts. I wonder if you can help me? Thanks.

  3. I am an investor of gate io, I have consulted a lot of information, I hope to upgrade my investment strategy with a new model. Your article creation ideas have given me a lot of inspiration, but I still have some doubts. I wonder if you can help me? Thanks.

  4. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me? https://www.binance.com/pl/register?ref=UM6SMJM3

  5. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me? https://accounts.binance.com/tr/register-person?ref=OMM3XK51

  6. Thanks for sharing. I read many of your blog posts, cool, your blog is very good.

  7. Reading your article helped me a lot and I agree with you. But I still have some doubts, can you clarify for me? I’ll keep an eye out for your answers.

  8. Cool. I spent a long time looking for relevant content and found that your article gave me new ideas, which is very helpful for my research. I think my thesis can be completed more smoothly. Thank you.

發表迴響