How to convert array into string without comma and separated by space in javascript without concatenation?

后端 未结 4 1282
余生分开走
余生分开走 2020-12-03 06:53

I know you can do this through looping through elements of array and concatenating. But I\'m looking for one-liner solutions. toString() and join() returns string with eleme

4条回答
  •  孤街浪徒
    2020-12-03 07:14

    Use the Array.join() method. Trim to remove any unnecessary whitespaces.

    var newStr = array.join(' ').trim()

提交回复
热议问题