深拷贝的deepClone函数
function deepClone(obj){
let newObj = obj.push?[]:{}; //如果obj有push方法则 定义newObj为数组,否则为对象。
for(let attr in obj){
if(typeof obj[attr] === 'object'){
newObj[attr] = deepClone(obj[attr]);
}else{
newObj[attr] = obj[attr];
}
}
return newObj;
}