var string = "Chemistry,English,History";
先生,我想将其转换为如下数组:
var subjects= ["Chemistry","English","History"];
使用jQuery
答案 0 :(得分:1)
不需要jquery。只需使用.split()函数即可实现此目的。
let string = 'Chemistry,English,History';
let arr = string.split(',');
console.log(arr)