How to check the particular property exists in nested array object using javascript;
In the below arrobj
, if value
property is empty, remove and return the array of object
If all object property value is empty, return [];
using javascript.
var arrobj = [
{
id: 1,
task: [
{tid:1, value:[]},
{tid:2, value:[12,13]}
]
},
{
id: 2,
task: [
{tid:4, value:[14,15]}
]
}
]
Tried
var valueExists = arrobj.filter(e=>e.tasks.filter(i =>i.value.length > 0);
Expected Output:
[
{
id: 1,
task: [
{tid:2, value:[12,13]}
]
},
{
id: 2,
task: [
{tid:4, value:[14,15]}
]
}
]
Via Active questions tagged javascript - Stack Overflow https://ift.tt/zN8KLeJ
Comments
Post a Comment