I\'m looking for the best solution to merge all objects in one array
const arrayOfObjects = [
{name: \'Fred\', surname: \'Shultz\'}, {name: \'Anne\', surnam
Here is a lodash approach
_(input).flatMap(_.entries).groupBy(0).mapValues(v => _.map(v, 1)).value()
var input = [
{name: 'Fred', surname: 'Shultz'}, {name: 'Anne', surname: 'Example'}
];
var res = _(input).flatMap(_.entries).groupBy(0).mapValues(v => _.map(v, 1)).value()
console.log(res);
This will take care if the objects doesn't have exactly same key sets