I have an obejct:
obj1 = {
id: 123,
name: "ABC test",
desc: "SPme test sdesctiption",
data: [{name:"data1"}],
createdBy: "Some person",
updatedBy: "Some persone22"
}
Now when we edit the details of this data from client side, we need to update only those fields from the object that has been changed. ex:
updatedObj = {
id: 123,
name: "ABC12222222 test", // changed
desc: "SPme test sdesctiption",
data: [{name:"data1"}],
createdBy: "Some person",
updatedBy: "Some persone22"
}
In above case I only want to change the name, but this data can be dynamic and based on what user changes, we need to update only thoe fields in the obj1
I tried :
newObj = Object.assign(obj1, {updatedObj})
but this inserts all new object inside obj1. I tried using Shallow copy of objects but that did not quite work.
any ideas how this can be achieved?