js 深拷贝函数
人气:0
function objectClone(obj,preventName){
if((typeof obj)=='object'){
var res=(!obj.sort)?{}:[];
for(var i in obj){
if(i!=preventName)
res[i]=objectClone(obj[i],preventName);
}
return res;
}else if((typeof obj)=='function'){
return (new obj()).constructor;
}
return obj;
}
if((typeof obj)=='object'){
var res=(!obj.sort)?{}:[];
for(var i in obj){
if(i!=preventName)
res[i]=objectClone(obj[i],preventName);
}
return res;
}else if((typeof obj)=='function'){
return (new obj()).constructor;
}
return obj;
}
加载全部内容