js处理数组问题,以及数组转化问题
var str="1,2,1,2,31,2";
var arr = str.split(",");
for (var i = 0; i < arr.length; i++) {
arr[i] = parseInt(arr[i])+1;
}
console.log(arr);
$.map( arr, function(n){
return n + 4;
});
[2, 3, 2, 3, 32, 3]
[6, 7, 6, 7, 36, 7]
var str="1,2,1,2,31,2";
var arr = str.split(",");
for (var i = 0; i < arr.length; i++) {
arr[i] = parseInt(arr[i])+1;
}
console.log(arr);
$.map( arr, function(n){
return n + 4;
});
[2, 3, 2, 3, 32, 3]
[6, 7, 6, 7, 36, 7]