I have two arrays of objects:
A = [
{ id1: "1", id2: "a", p1: "3", p2: "4" },
{ id1: "1", id2: "b", p1: "5", p2: "6" },
{ id1: "2", id2: "a", p1: "7", p2: "8" },
{ id1: "2", id2: "b", p1: "9", p2: "10" }
];
B = [
{ id1: "1", id2: "a", p3: "13", p4: "14" },
{ id1: "1", id2: "b", p3: "15", p4: "16" },
{ id1: "2", id2: "a", p3: "17", p4: "18" },
{ id1: "2", id2: "b", p3: "19", p4: "20" }
];
I need a function that makes an inner join between the two objects based on the two properties id1 and id2, making a union of the other properties (properties names are never equal except for id1 and id2)
In other words I need as a result:
C = [
{ id1: "1", id2: "a", p1: "3", p2: "4", p3: "13", p4: "14" },
{ id1: "1", id2: "b", p1: "5", p2: "6", p3: "15", p4: "16" },
{ id1: "2", id2: "a", p1: "7", p2: "8", p3: "17", p4: "18" },
{ id1: "2", id2: "b", p1: "9", p2: "10", p3: "19", p4: "20" }
];
In here I can find a way to make the join using one single key. I need an extention for the multiple keys case.