标签:blog io ar for sp 数据 div on cti
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的全局溢出赋值,可改变形参所指向的实参的本身值
标签:blog io ar for sp 数据 div on cti
原文地址:http://www.cnblogs.com/liujinyu/p/4023633.html