I have two arrays of objects. example
data1 = [{
foo: '2',
box: 'yes',
id: '1234'
}, {
foo: '34',
box: 'no',
id: '1235'
}];
data2 = [{
key: 'value',
key: 'value',
id: '1234'
}, {
key: 'value',
key: 'value',
id: '1235'
}];
I need it like this based on matching id value : each obj has a unique key id, that much the second array.
finalData = [{
foo: '2',
box: 'yes',
id: '1234',
key: 'value',
key: 'value'
}, {
box: '34',
box: 'no',
id: '1235',
key: 'value',
key: 'value'
}];
basically merging the two arrays of objects based on key id .