javascript - How to use loadash to compare arrays of the form [object, object, object]
我想大声告诉你
我想大声告诉你 2017-06-28 09:28:33
0
1
749

Array a

var a = [{key:1,name:'name1'},{key:2,name:'name2'},{key:3,name:'name3'},{key:4,name:'name4'},{key:5,name:'name5'}];

When array b is var b = [{key:1,name:'name1'}];, the final result should be [{key:2,name:'name2' },{key:3,name:'name3'},{key:4,name:'name4'},{key:5,name:'name5'}]

When array b is var b = [{key:3,name:'name3'},{key:4,name:'name4'}];, the final result should be [{key:1,name:'name1'},{key:2,name:'name2'},{key:5,name:'name5'}]

That is, I want to get the result of array a-array b.

Using difference is only effective for arrays, not for objects inside it

var a2 = [1,2,3,4,5];
        var b2 = [1,5];
        console.log(_.difference(a2,b2))
我想大声告诉你
我想大声告诉你

reply all(1)
漂亮男人
_.differenceWith(a, b, _.isEqual)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template