remove empty values array lodash code example
Example 1: lodash remove not in array
var a = [
{id: 1, name: 'A'},
{id: 2, name: 'B'},
{id: 3, name: 'C'},
{id: 4, name: 'D'}
];
var removeItem = [1,2];
removeItem.forEach(function(id){
var itemIndex = a.findIndex(i => i.id == id);
a.splice(itemIndex,1);
});
console.log(a);
Example 2: remove empty object from array lodash
var myArrayFiltered = myArray.filter((ele) => {
return ele.constructor === Object && Object.keys(ele).length > 0
});