I have an existing JSON and I take part of the JSON and modify it by creating a new JSON. Now, when I do a console.log of the existing JSON, it shows the existing JSON to have the updates done on the new JSON. Why is that happening ? (I'm doing this in React)
var newJSON = [];
let ifruleObject = oldJSON.rules[0].rules;
console.log(oldJSON);
ifruleObject.forEach((e) => {
for( var i=0; i<ifruleObject.length; i++)
{
if(ifruleObject[i].length <= 3)
{
ifruleObject[i]={ruleid:ifruleObject[i-1].id, rulecombinator: ifruleObject[i]};
newJSON .push(ifruleObject[i]);
}
}
});
console.log(newJSON);