lodash remove the same value 2 array code example
Example 1: 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'); //removed if had duplicate id
var uniqueUsers = _.uniqWith(users, _.isEqual);//removed complete duplicates
Example 2: lodash remove multiple items from array
var colors = ["red","blue","green","yellow"];
var removedColors = _.remove(colors, function(c) {
//remove if color is green or yellow
return (c === "green" || c === "yellow");
});
//colors is now ["red","blue"]
//removedColors is now ["green","yellow"]