I have an array of objects
[
{
id1: {
props1: 1,
props2: 2,
props3: 3
}
},
{
id2: {
props1: 1,
props2: 3,
props3: 4
}
},
{
id3: {
props1: 1,
props2: 2,
props3: 4
}
},
{
id4: {
props1: 2,
props2: 2,
props3: 3
}
},
{
id5: {
props1: 2,
props2: 2,
props3: 4
}
}]
I want to compare elements (objects) each other to get all couple of objects containing same props1
and props2
So my result should be
[
[
{
id1: {
props1: 1,
props2: 2,
props3: 3
}
},
{
id3: {
props1: 1,
props2: 2,
props3: 4
}
}
],
[
{
id4: {
props1: 2,
props2: 2,
props3: 3
}
},
{
id5: {
props1: 2,
props2: 2,
props3: 4
}
}
]
]
Is there any way to compare 2 elements (objects) each other without using 2 for-loop? I'm worried about the performance of 2 for-loop solution when the size of array is a big number