Now Deep Copy Example: The following snippet replaces the Ob | Dedicated Coders
Now Deep Copy Example:
The following snippet replaces the Object.assign() method by the JSON methods to carry a deep copy the person object:
let personalInfo = {
firstName: 'Mirzoyoqub',
lastName: 'Rashidov',
address: {
street: 'Chilonzor',
city: 'Tashkent',
}
};
let copiedpersonalInfo = JSON.parse(JSON.stringify(personalInfo));
copiedpersonalInfo.firstName = 'John'; // disconnected
copiedpersonalInfo.address.street = 'Oqqo'rg'on';
console.log(personalInfo);
edited)