There are two Arrays of Objects, Arr1 and Arr2. The goal is to merge these two arrays based on their 'id' values. If Arr1 does not contain any object with the same id as in Arr2, then that particular object node should be pushed into Arr1. How can this be achieved?
Arr1 =
[
{
'id': 101,
'name': "ABC"
},
{
'id': 202,
'name': "DEF"
}
];
Arr2 =
[
{
'id': 303,
'name': "PQR"
},
{
'id': 404,
'name': "XYZ"
},
{
'id': 202,
'name': "DEF"
}
];
Arr1 =
[
{
'id': 101,
'name': "ABC"
},
{
'id': 202,
'name': "DEF"
},
{
'id': 303,
'name': "PQR"
},
{
'id': 404,
'name': "XYZ"
}
];