I was trying to copy the contents of a particular JSON to another JSON and modify the temporary variable to my needs but the original JSON is also getting changed.
For example :
count = {
passed : 2,
failed : 5
}
console.log(count) // logs the JSON content
let temp = count;
console.log(temp) // logs the JSON content
Say, now I'm modifying the temp, like :
temp.passed = 0;
console.log(temp); //{passed : 0, failed : 5}
It is also changing the passed value of count too. Now if I log JSON of count,
console.log(count); //{passed : 0, failed : 5}
where I want the passed to be 2, since I only modified the JSON object of passed in temp.
I want to keep the count to be same and modify only the temp. Can someone help me out ?