深拷贝
function deepClone(source){
if(typeof source !== 'object' || source === null){
return source;
}
let targetObj = source.constructor === Array ? [] : {} ;
for(keys in source){
targetObj[keys] = deepClone(source[keys])
}
return targetObj
}
let obj = {
a: [1, 2, {a:1,b:[1,2,3]}, 4],
b: 2
}
// let obj1 = obj
let obj1 = deepClone(obj)
obj1.a.push(5)
obj1.a[2].b.push(9)
console.log(obj1, obj);