1Lodash
2var a = [
3 { userId:"p1", item:1},
4 { userId:"p2", item:2},
5 { userId:"p3", item:4}
6];
7
8var b = [
9 { userId:"p1", profile:1},
10 { userId:"p2", profile:2},
11 { userId:"p4", profile:4}
12];
13var merged = _.merge(_.keyBy(a, 'userId'), _.keyBy(b, 'userId'));
14var values = _.values(merged);
15console.log(values);
16<script src="https://cdnjs.cloudflare.com/ajax/libs/