function deepCopy(obj) {
if (typeof obj !== 'object') return;
let result = obj instanceof Array ? [] : {};
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
result[key] = typeof obj[key] === 'object'
&& !(obj[key] instanceof Date) ? deepCopy(obj[key]) : obj[key];
}
}
return result;