This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const deepClone = (obj) => { | |
if (obj === null || typeof obj !== "object") return obj; | |
let clone = Array.isArray(obj) ? [] : {}; | |
for (const key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
clone[key] = | |
obj[key] instanceof Date | |
? new Date(obj[key].getTime()) | |
: deepClone(obj[key]); | |
} |