var obj = {
a: 1,
b: 2,
c: {
fun: function (){
console.log('傻逼老板,真抠')
}
}
}
var newObj = JSON.parse(JSON.stringify(obj))
var arr = [1,2,34,56,8]
function deepClone(obj){
var newObj1 = null
if(typeof obj !== Object){
return obj
}else if(typeof obj === Object && obj !== null){
newObj1 = obj instanceof Array? [] : {}
for(var key in obj){
if(typeof obj[key] == Object){
deepClone(obj[key])
}else{
newObj1[key] = obj[key]
}
}
}
return newObj1
}
console.log(deepClone(obj))
console.log(deepClone(arr))
console