I need to delete an property/key from one object comparing the other as in the below example
var Obj1 ={
a : '1',
b : '2',
c : '3',
d : '4'
}
var Obj2 ={
a : '1',
b : '2',
d : '5'
}
for (const key in Obj1) {
if (!Obj2.hasOwnProperty(key)) {
delete Obj1[key];
}
}
I have two objects Obj1
and Obj2
. Need to compare two Objects and remove the missing key in Obj1
. that is I am removing key c
from Obj1
.
It is working as expected. What I am wondering is whether new Object reference is created for this Obj1 after deleting or the Object reference is same?
How to find that?