且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将逗号分隔的字符串转换为数组

更新时间:2023-11-06 17:20:22

var array = string.split(',');

MDN参考,主要有助于 limit 参数可能出现意外行为。 (提示:a,b,c.split(,,2)出现在 [a,b] ,而不是 [a,b,c] 。)

MDN reference, mostly helpful for the possibly unexpected behavior of the limit parameter. (Hint: "a,b,c".split(",", 2) comes out to ["a", "b"], not ["a", "b,c"].)