function loading(){
var str="a=a1&b=b1&c=c1&d=undefined&e=undefined";
console.log(getRealParams(str));
}
function getRealParams (param) {
var new_str="";
var str_ary=param.split("&");
for (var i =0 ;i<str_ary.length;i++) {
var reg=new RegExp("undefined");
if (!reg.test(str_ary[i])) {
new_str=str_ary[i]+"&" + new_str;
}
}
return new_str.substring(0,new_str.length-1);
}
js中去除字符串中为undefined的字符串
最新推荐文章于 2024-02-04 16:38:20 发布