Transform Javascript Array into delimited String

后端 未结 7 831
别那么骄傲
别那么骄傲 2020-12-03 04:23

I have a Javascript string array with values like A12, B50, C105 etc. and I want to turn it into a pipe delimited string like this: A12|B50|C105...

How could I do th

7条回答
  •  没有蜡笔的小新
    2020-12-03 05:01

    For a native JavaScript array then myArray.join('|') will do just fine.

    On the other hand, if you are using jQuery and the return value is a jQuery wrapped array then you could do something like the following (untested):

    jQuerySelectedArray.get().join('|')
    

    See this article for more information.

提交回复
热议问题