Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

merge two arrays of objects lodash

const array1 = [{id:1, name:'doc1'}, {id:2, name:'doc2', {id: 3: "test"}}];
const array2 = [{id:1, name:'doc1'}, {id:3, name:'doc3'}, {id:4, name:'doc4'}];

const result = _.unionBy(array1, array2, 'id');
console.log(result);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #merge #arrays #objects #lodash
ADD COMMENT
Topic
Name
4+2 =