I have a JavaScript-array with objects filled in and want to remove every object with no data. It might look like this:
var myArray = [ {id: \"28b\", text:\"Phil
// Code goes here
myArray = [{
id: "28b",
text: "Phill"
}, {
id: "12c",
text: "Peter"
}, {
id: "43f",
text: "Ashley"
}, {
id: "43f",
text: "Ashley"
}, {
id: "",
text: ""
}, {
id: "9a",
text: "James"
}, {
id: "",
text: ""
}, {
id: "28b",
text: "Phill"
}
]
var result = _.filter(_.uniq(myArray, function(item, key, a) {
return item.id;
}), function(element) {
return element.id && element.text
});
console.log(result)