set-operations

Difference and intersection of two arrays containing objects

倾然丶 夕夏残阳落幕 提交于 2019-11-26 08:16:53
问题 I have two arrays list1 and list2 which have objects with some properties; userId is the Id or unique property: list1 = [ { userId: 1234, userName: \'XYZ\' }, { userId: 1235, userName: \'ABC\' }, { userId: 1236, userName: \'IJKL\' }, { userId: 1237, userName: \'WXYZ\' }, { userId: 1238, userName: \'LMNO\' } ] list2 = [ { userId: 1235, userName: \'ABC\' }, { userId: 1236, userName: \'IJKL\' }, { userId: 1252, userName: \'AAAA\' } ] I\'m looking for an easy way to execute the following three