How can you clone an object using the spread syntax and preserve the object's prototype?
const obj1 = { name: "John", age: 30 };
const obj2 = { ...Object.getPrototypeOf(obj1), ...obj1 };
obj2.age = 35;
console.log(obj1.age);
How can you clone an object using the spread syntax and preserve the object's prototype?
const obj1 = { name: "John", age: 30 };
const obj2 = { ...Object.getPrototypeOf(obj1), ...obj1 };
obj2.age = 35;
console.log(obj1.age);