JS 将数字字符串转为 数字数组
将字符串转化为数组主要代码:
let str = \'3,4,5,6\' let arr = str.split(",").map(Number); console.log(arr) //结果:[3,4,5,6]
将数字数组转化为字符串数组
let arrs = [1, 2, 3, 4, 5, 6, 7, 8, 9];
let strArr = arrs.map(String); //结果: [\'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\']
let newStr = strArr.join(\',\');
console.log(newStr)//结果为:1,2,3,4,5,6,7,8,9