将具有一个元素的数组拆分为具有多个元素的数组

splitting an array with one element into an array with many elements

本文关键字:元素 数组 具有一 拆分 有一个      更新时间:2023-09-26

我想取这个包含一个项目的数组(一个带有一堆逗号分隔项目的字符串

["Bucknell Venture Plan Competition, Mitch Blumenfeld, DreamIt Ventures, Deep Fork Capital, John Ason, Mitchell Blumenfeld, Gianni Martire"]

我想把它变成这样。包含每个名称作为单独数组项的数组。

["Bucknell Venture Plan Competition", "Mitch Blumenfeld", "DreamIt Ventures", "Deep Fork Capital", "John Ason", "Mitchell Blumenfeld", "Gianni Martire"]

谢谢!

更新:

感谢您的帮助。成功了!

简单如下:

var myArr = ["Bucknell Venture Plan Competition, Mitch Blumenfeld, DreamIt Ventures, Deep Fork Capital, John Ason, Mitchell Blumenfeld, Gianni Martire"];
var myNewArr = myArr[0].split(",");

我认为这应该有效:

var items = ["Bucknell Venture Plan Competition, Mitch Blumenfeld, DreamIt Ventures, Deep Fork Capital, John Ason, Mitchell Blumenfeld, Gianni Martire"];
var array = items[0].split(",");