function copyDeep(obj){ if (typeof obj === 'object'&& obj!=null) { let target = Array.isArray(obj)?[]:{}; for(let i in obj){ if(Object.prototype.hasOwnProperty.call(obj,i)){ if(typeof obj === 'object'&& obj!=null){ target[i]=copyDeep(obj[i]) } else { target[i]=obj[i] } } } return target; } else { return obj; } }