lodash remove undefined from array code example
Example 1: lodash remove undefined values from array
var colors = ["red",undefined,"","blue",null,"crap"];
var cleanColors=_.without(colors,undefined,null,"","crap");
Example 2: lodash remove element from list
var colors = ["red","blue","green","green"];
var greens = _.remove(colors, function(c) {
return (c === "green");
});
Example 3: remove element from array lodash
var arr = [1, 2, 3, 3, 4, 5];
_.remove(arr, function(e) {
return e === 3;
});
console.log(arr);