Remove Object From "object Of Objects"
I have a Object that contain objetcs like this.Object {MAILING ADDRESS: 'P O BOX 59', APN: '066-102-11-1'} . Now I need data without empty Object. Like I get output like this Outpu
Solution 1:
You can use filter option like this. You can change your object to array and apply filter.
var someArray = $.map(obj_field, function(value, index) {
return [value];
});
someArray = [{
MAILINGADDRESS: "P O BOX 59",
APN: "066-102-11-1"
},
{
MAILINGADDRESS: "",
APN: ""
},
{
MAILINGADDRESS: "P O BOX 59",
APN: "066-102-11-1"
}, {
MAILINGADDRESS: "",
APN: ""
}
];
result = someArray.filter(function(el) {
return el.APN !== "";
});
console.log(JSON.stringify(result, null, ' '));
Post a Comment for "Remove Object From "object Of Objects""