Javascript 深度克隆
Object.prototype.clone=function(){
var o=this.constructor===Array?[]:{};
for(var e in this){
o[e]=typeof this[e]==="object"?this[e].clone():this[e];
}
return o;
}
举例:
var obj1 = {name: "flondon", add: "China"};
console.info(obj1.clone());

浙公网安备 33010602011771号