How to use Lodash to merge two collections based on a key?
Second highest voted answer doesn’t do proper merge. If second array contains an unique property, it is not taken into account. This approach does a proper merge. 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} … Read more