const obj = {a:10,b:{c:[20,30,40],d:{e:50,f:60}}}
function deelpCloneObject(obj) {
if(obj === null || typeof obj !== "object"){
return obj
}
if(Array.isArray(obj)){
const copyArr = []
for(let value of obj){
copyArr.push(deelpCloneObject(value))
}
return copyArr
}
const cloneObj = {}
for(let [key, value] of Object.entries(obj)){
cloneObj[key] = deelpCloneObject(value)
}
return cloneObj
}
const deepCopyOfobj = deelpCloneObject(obj)
deepCopyOfobj.b.d.f = ["string1"]
console.log(deepCopyOfobj)
console.log(obj)
To embed this project on your website, copy the following code and paste it into your website's HTML: