I have two objects with unequal length, I want to merge based on "mac_id". I worked with lodash _.merge()
, but it is incompatible with the lengths of variable objects.
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 received the necessary data, but not structured.
What methods should be used to get the final result?
[
{ 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' } ]
source
share