Does Array values concat instead of be replaced?
Shoroh opened this issue · comments
Alexandr Shelestov commented
I'm not sure, if this a bug or a feature. Look:
import merge from 'merge-deep';
const object1 = { a: '1', b: '2', c: [1, 2, 3] };
const object2 = { a: undefined, b: null, c: null }; // 'c' property might be anything else, like '1', or undefined, or an empty Array, doesn't matter
const mergedObject = merge(object1, object2);
console.log(mergedObject);
=> { a: undefined, b: null, c: [1, 2, 3] } // So, the last property is not changed.
If 'c' in the object2 was 'abc', we'll get
=> { a: undefined, b: null, c: ['abc', 1, 2, 3] }
It looks like Array type values concat, instead of be replaced with a new value. But I need a tool to replace values while merging.
Should I use assign-deep instead? Cause the last one does it well.