本文翻译自:Easy way to turn JavaScript array into comma-separated list?
I have a one-dimensional array of strings in JavaScript that I'd like to turn into a comma-separated list. 我在JavaScript中有一个一维的字符串数组,我想把它变成以逗号分隔的列表。 Is there a simple way in garden-variety JavaScript (or jQuery) to turn that into a comma-separated list? 在花园种类的JavaScript(或jQuery)中有一种简单的方法可以将其转换为以逗号分隔的列表吗? (I know how to iterate through the array and build the string myself by concatenation if that's the only way.) (我知道如何迭代数组并通过连接自己构建字符串,如果这是唯一的方法。)
#1楼
参考:https://stackoom.com/question/qTc/将JavaScript数组转换为逗号分隔列表的简便方法
#2楼
The Array.prototype.join() method: Array.prototype.join()方法: