Suppose I have an object a as a = {id: 1, name: 'abc'}.
And I have another object b as
b = {id:2} OR
b = {name: 'trp'} OR
b = {} Now, I want to be able to compare and assign a and b (like a=b) in such a way, that whichever property b holds it updates in a, and if it doesn't hold any property, a remains the same.
eg
a= {id: 1, name: 'abc'} b= {name: 'trp'} a=b //should give output a= {id: 1, name: 'trp'} ALSO it might be that the solution to this question is pretty simple. VERY NICE. just post it. Whatever the solution is, it's clearly tripping over my head.
Arigatou gozaimasu
EDIT there can also be a third scenario where
b = {id: 2, name: 'trp', title:'not required'} in that case also the statement comparing and assigning values of b to a should give result {id: 2, name: 'trp'} i.e. No merging
a=bcan be achieved usinga = Object.assign(a, b);... but as for comparing? that's complexahas id =1,bhas id =2, there's a difference in key 'id' and soaid will be updated.