I have a console.log
on an object, then I delete
a key, then console.log
again. The code below behaves as expected, the first console log
has one
and two
and the second console log
only has two
const a = {
one: '1',
two: '2'
}
console.log(a);
// Will print { one: "1", two: "2" }
delete a.one;
console.log(a);
// Will print { two: "2" }
However my actual code behaves strangely. If I just log the object I see the value I expect:
console.log(a);
// Will print { one: "1", two: "2" }
If I delete
then the key is deleted for both console logs, even though one appears first in the code:
console.log(a);
// Will print { two: "2" }
delete a.one;
console.log(a);
// Will print { two: "2" }
I cant share my full project and I havent been able to recreate this behaviour. I know this is an open question but what are the potential causes of this behaviour?