js 对象深拷贝
function deepObj(obj){ var dest={}; for(var key in obj){ if(typeof obj[key]==='object'){ dest[key]=obj[key].constructor===Array?[]:{}; deepObj(dest[key],obj[key]); }else{ dest[key]=obj[key] } } return dest; } var obj={name:'aa',addr:'werwer',arr:[{name12:'aa',addr12:'werwer'}]} var des=deepObj(obj) des.arr.name12='aaaaa' console.log(des) console.log(obj)