Let's say I have the variables 'state' and 'newState'. I would like to create a pure function that returns 'state' updated with the properties (and sub properties) of 'newState'. Here is an example:
const state = {id:1, name:'aName', description: 'aDescription'};
const newState = {id:1, name:'newName', subItems: {id:3, type:'whatever'}};
The function would return:
{id:1, name:'newName', subItems: {id:3, type:'whatever'}}
I could use rest parameters but I don't know how to append as opposed to override. I can't just loop through the properties because I want the function to be pure (redux reducer).
Anyone have any ideas?