I have to merge two objects but I don't want to assign undefined value to defined values.
A = { activity: 'purchased', count: undefined, time: '09:05:33' }
B = { activity: 'purchased', count: '51', time: undefined }
When I try Object.assign, undefined is replacing fields that have values.
What I want
C = { activity: 'purchased', count: '51', time: '09:05:33' }
You could use lodash's merge command. C = _.merge(A,B);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With