I have two objects with unequal lengths, I want to merge based on 'mac_id'. I was working with lodash _.merge()
, but it is not compatible with variable object lengths.
obj4=[
{ mac_id: '00-17-0d-00-00-30-47-fa',
sent_mail_time: '2017-09-28 11:07:0' },
{ mac_id: '00-17-0d-00-00-30-48-18',
sent_mail_time: '2017-09-28 11:07' }
];
obj3=[
{ mac_id: '00-17-0d-00-00-30-4d-94',
notif_time: '2017-09-28 10:16:28' },
{ mac_id: '00-17-0d-00-00-30-47-fa',
notif_time: '2017-09-28 10:14:28' },
{ mac_id: '00-17-0d-00-00-30-49-58',
notif_time: '2017-09-28 10:26:28' } ]
Using _.groupBy('mac_id')
I got the desired data but not in a structured way.
what methods do I need to follow to get the final result to be like this?
[
{ mac_id: '00-17-0d-00-00-30-4d-94',
notif_time: '2017-09-28 10:16:28' },
{ mac_id: '00-17-0d-00-00-30-47-fa',
sent_mail_time: '2017-09-28 11:07:0',
notif_time: '2017-09-28 10:14:28' },
{ mac_id: '00-17-0d-00-00-30-49-58',
notif_time: '2017-09-28 10:26:28' },
{ mac_id: '00-17-0d-00-00-30-48-18',
sent_mail_time: '2017-09-28 11:07' } ]