Here are two arrays I need to merge:
var arrayOne = [
{id: 10, content: '10 - dolor'},
{id: 12, content: '12 - sit'},
{id: 54, content: '54 - from first'}
];
var arrayTwo = [
{id: 2, content: '2 - lorem'},
{id: 54, content: '54 - from second'},
{id: 80, content: '80 - ipsum'}
];
Is there a way to merge them based on id without duplicates? I attempted it using LoDash, but couldn't find a suitable solution.
The desired merged result would be:
var mergedArray = [
{id: 10, content: '10 - dolor'},
{id: 12, content: '12 - sit'},
{id: 54, content: '54 - from first'},
{id: 2, content: '2 - lorem'},
{id: 80, content: '80 - ipsum'}
];
An efficient solution is crucial as the data source will be extensive.