// 复制对象
export const deepCopy = (obj) =>{
let gettype=Object.prototype.toString
if(typeof obj !='object' ||gettype.call(obj) ==='[object Date]'){
return obj;
}
if(Object.prototype.toString.call(obj) ==='[object Array]') {
return obj
}
let newobj = {};
for (let attr in obj) {
newobj[attr] =deepCopy(obj[attr]);
}
return newobj;
}
let obj1 = deepCopy (obj)
console.log(obj1)
网友评论