Suppose, I have two nested objects defined as:
let obj1={
work:{
title: "work",
description: "All that is to be done.",
view: 1
},
task:{
title: "open"
}
},
obj2={
work:{
title: "Work",
view: null
},
person: "Aniruddha Sarkar"
},
obj3={
task: "open"
};
What would be the most efficient function, say updateObj
, which will produce the following results?
updateObj(obj1,obj2);
Output:
{
work:{
title: "Work",
description: "All that is to be done."
},
task:{
title: "open"
},
person: "Aniruddha Sarkar"
}
And,
updateObj(obj1,obj3);
Output:
{
work:{
title: "work",
description: "All that is to be done.",
view: 1
},
task:"open"
}