lodash remove object from array by property code example
Example 1: lodash delete object property
var result = _.omit(credentials, ['age']);
var result = _.pick(credentials, ['fname', 'lname']);
Example 2: lodash remove element from list
var colors = ["red","blue","green","green"];
var greens = _.remove(colors, function(c) {
return (c === "green");
});
Example 3: lodash remove multiple items from array
var colors = ["red","blue","green","yellow"];
var removedColors = _.remove(colors, function(c) {
return (c === "green" || c === "yellow");
});
Example 4: lodash delete object property
var model = {
fname:null,
lname:null
};
var credentials = {
fname:"xyz",
lname:"abc",
age:23
};
var result = _.pick(credentials, _.keys(model));
console.log(result);