This is my object
const person = {
name: "Vikram",
age: 21,
place: {
country: "India",
state: "Karnataka",
},
marks: [1, 2, 3, 4],
parents: {
father: "Ramesh",
mother: "Suma",
},
};
function cloneDeep(obj){}
that should create a deep copy of the provided object using recursion and methods like Object.create etc. Please help me to deep copy this object using recursion.
Yes, you can alter the Object class prototype:
if (!Object.prototype.hasOwnProperty.call(Object.prototype, "deepClone")) {
Object.prototype.deepClone = () => {
console.log('clone!')
};
}
const obj1 = { x: 1 };
obj1.deepClone();