var formateNumArr = function(arr,defaultVal){
var a = [];
$.each(arr,function(i,v){
if(!isNaN(v)){
a.push(v);
}else{
a.push(defaultVal);
arr[i] = '';//对不合法数据进行清空处理
}
});
return a;
}
var arr1 = [12,4,1,'tw',515,13];
var aa = formateNumArr(arr1,6)
console.log(aa,arr1) //[12,4,1,6,515,13] [12,4,1,'',515,13]
var a = [];
$.each(arr,function(i,v){
if(!isNaN(v)){
a.push(v);
}else{
a.push(defaultVal);
arr[i] = '';//对不合法数据进行清空处理
}
});
return a;
}
var arr1 = [12,4,1,'tw',515,13];
var aa = formateNumArr(arr1,6)
console.log(aa,arr1) //[12,4,1,6,515,13] [12,4,1,'',515,13]