Intersection and union two arrays by key
I have two arrays with objects:
const arr1 = [{ id: 1, paramA: 'value1' }, { id: 2, paramA: 'value2' }];
const arr2 = [{ id: 2, paramB: 'value11' }, { id: 3, paramB: 'value22' }];
Want something like that:
const res = combine(arr1, arr2, 'id');
And expect intersection of two arrays:
res = [{ id: 2, paramA: 'value2', paramB: 'value11' }];
Same questions: https://stackoverflow.com/questions/38612972/how-to-merge-two-arrays-of-objects-by-id-using-lodash https://stackoverflow.com/questions/38505448/how-to-merge-multiple-array-of-object-by-id-in-javascript
I miss this method in lodash. I would find it very useful.
I’d like to work on this issue to implement a utility to merge arrays of objects by a key. I can create a PR that handles intersections and merging of properties. Could you please assign this issue to me?
@KirtiGautam620 no, issues are never assigned in open source - but separately, this doesn't have a "help wanted" label, so it's not yet decided to accept it.