I have 2 deep nested object of objects. One is a "base" object and the other is a modified one.
I essentially want to "delete" the base object from the modified object and return an object that only contains different data. Here is an example:
Base object:
baseObj : {
image: {
width: '100%',
paddingTop: '0px',
paddingRight: '0px',
paddingBottom: '0px',
paddingLeft: '0px'
},
wrap: {
marginTop: '0px',
marginRight: '0px',
marginBottom: '0px',
marginLeft: '0px'
}
}
Object with modified data
mergedObject : {
image: {
width: '100%',
paddingTop: '0px',
paddingRight: '24px', // modified value
paddingBottom: '24px', // modified value
paddingLeft: '0px'
},
wrap: {
height: '100px', // new value
marginTop: '24px', // modified value
marginRight: '0px',
marginBottom: '0px',
marginLeft: '24px' // modified value
}
}
I would like an object that is returned like this:
diffObject : {
image: {
paddingRight: '24px',
paddingBottom: '24px',
},
wrap: {
height: '100px',
marginTop: '24px',
marginLeft: '24px'
}
}
The nesting could go a little deeper so it needs to be dynamic. Is there a way using lodash or some other library?