White Github logo

pavle-doby

Pavle Marinkovic

deepCopy2.js
// Hack with JSON pares & stringify
const newObj = JSON.stringify(JSON.parse(obj));  

🥈

deepCopy1.js
import { cloneDeep } from "lodash";              
// Fn from npm package lodash
const newObj = cloneDeep(obj);

🥉

deepCopy3.js
// Built-in JS function 🤩
const newObj = structuredClone(obj);             

🥇

JavaScript logo

Deep Copy an Object