日期:2014-05-16  浏览次数:20286 次

js实现clone
function cloneObject(obj){
var result = new Object();
var resultArray = new Array();

for(var v in obj){

var o = obj[v];

if(typeof o == "object" ){
if(o instanceof Array){
for(var i = 0; i < o.length ; i ++){
resultArray.push(o[i]);
}
result[v] = resultArray;
}else{
o = this.cloneObject(o);
result[v] = o;
}
}else{
result[v] = o;
}
}

return result;
}