最佳答案
我得到一个数组后,一些操作。我需要转换所有的数组值为整数。
我的示例代码
var result_string = 'a,b,c,d|1,2,3,4';
result = result_string.split("|");
alpha = result[0];
count = result[1];
// console.log(alpha);
// console.log(count);
count_array = count.split(",");
count_array现在包含 1,2,3,4,但我需要这些值是整数。
我已经使用了 parseInt(count_array);,但是它失败了。 JS 认为这个数组中的每个值都是字符串。