lodash compare arrays code example
Example 1: lodash deep compare two objects
var bob = {"sex":"male","age":21};
var bill = {"sex":"male","age":21};
if(_.isEqual(bob, bill)){
}else{
}
Example 2: Lodash remove duplicates from array
var users = [
{id:1,name:'ted'},
{id:1,name:'ted'},
{id:1,name:'bob'},
{id:3,name:'sara'}
];
var uniqueUsersByID = _.uniqBy(users,'id');
var uniqueUsers = _.uniqWith(users, _.isEqual);
Example 3: diff two arrays lodash
_.difference([2, 1], [2, 3]);
Example 4: lodash compare array without order
var array1 = [['a', 'b'], ['b', 'c']];
var array2 = [['b', 'c'], ['a', 'b']];
_.isEqual(array1.sort(), array2.sort());