Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Intersection and union two arrays by key #6044

Copy link
Copy link
@n1ks0N

Description

@n1ks0N
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.