how to merge 2 object array by the same key with lodash

Lodash
var a = [
  { userId:"p1", item:1},
  { userId:"p2", item:2},
  { userId:"p3", item:4}
];

var b = [
  { userId:"p1", profile:1},
  { userId:"p2", profile:2},
  { userId:"p4", profile:4}
];
var merged = _.merge(_.keyBy(a, 'userId'), _.keyBy(b, 'userId'));
var values = _.values(merged);
console.log(values);
<script src="https://cdnjs.cloudflare.com/ajax/libs/

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
merge oobject in array lodash merge object with another object lodash lodash merge 3 objects merge duplicate objects lodash merge multiple arrays lodash combine multiple arrays lodash merge two arrays based on key lodash merge two array of objects unique by keys lodash merge all objects in array lodash javascript lodash merge two objects sum values add two array into once lodash merge array of objects lodash lodash merge keys by loadash merge two arrays of objects by key keep common only loadash merge two arrays of objects by key keep common ony loadash merge two arrays of objects by key merge two array of objects in sorted order on id lodash lodash merge two objects with same key lodash merge objects with same keys merge two array lodash lodash merge objects with second object value lodash 2 objects merge together lodash merge object keys lodash 2 objects merge deep merge two js objects with some common keys lodash merge two objects javascript lodash lodash merge object with same key lodash merge two objects changing one value lodash merge object merge two array of objects with same key using lodash add arrray in new key how to merge two object arrays in javascript with lodash merge 2 aarray by id lodash lodash combine array of objects merge array of objects duplicates with lodash merge objects in array lodash lodash merge two array of string merge two objects of same keys nodejs using lodash merge 2 arrays lodash lodash combine two objects lodash merge two arrays with same key javascript merge two objects with same key lodash lodash marge duplicates in array of objects Merge Duplicate Objects in an Array of Objects using lodash Merge duplicate objects in single array using lodash lodash merge two array js merge two objects with same keys lodash combine data in 2 objects lodash lodash merge array of objects preserve key merge 2 array in lodash merge 2 object by unknow keys lodash merge 2 objects with same keys lodash mergeWith same key lodash merge 2 object same key lodash merge same key objects lodash merge objects with same key lodash lodash merge two objects deep lodash concat 2 arrays of objects lodash merge objects in array merge an array of objects lodash how to marge douplicate array object value using lodash merge duplicate objects in array lodash lodash merge two object How to merge two arrays of objects by ID using lodash? [duplicate] lodash merge two arrays of objects by key merge two array of object by key lodash merge two array replace by key lodash lodash merge two array by key javascript merge multiple objects in array lodash merge two array of objects javascript based on a key lodash lodash merge 2 arrays lodash merge 3 object lodash two array merge by id how to merge two array of objects in javascript es6 using lodash lodash add two object values with same key name lodash merge two object values with same key name lodash merge array into object merge array of objects javascript lodash cover to object merge array of objects javascript lodash lodash merge objects by key lodash to merge two object and make new object loadsh merge objects by key merge array values lodash merge two objects lodash merge two object lodash lodash merge objects in array by key lodash merge array of objects into one object lodash merge 2 objects lodash merge array objects lodash merge array of objects &quot;existing&quot; properties lodash merge array of objects existing properties lodash merge array of objects by key javascript merge array of objects by key lodash merge two arrays Lodash based on the object key vals merge two arrays of objects lodash two arrays join in same array lodash lodash merge array of objects without duplicates lodash deep merge multiple objects lodash merge objects with same variable lodash merge multiple arrays lodash merge array of objects and put different values in array lodash merge two objects lodash merge 2 arrays into one object merge arrays of objects with lodash lodash merge and update two array lodash merge two list on key lodash combine two arrays of objects and mark duplicates lodaSH merge array into single array lodash merge values of all keys of object lodash merge values of all keys merge 2 object lodash lodash merge two objects without duplicates lodash merge two arrays of objects without duplicates lodash merge two arrays of objects lodash merge array of objects merge two array of objects based on a key lodash lodash merge array of object lodash.merge merge javascript objects in array with same key lodash lodash merge objects with same key how to merge 2 object array by the same key with lodash how to merge 2 object array by the same key with lodash
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source