i've an array
const exampleArray = [
{
id: 1,
name: test
},
{
id: 1,
name: test
},
{
},
]
now the array exampleArray
live inside another array of objects so
const exampleNest = [{
property1: {},
property2: [],
exampleArray: [{...}],
}]
I need to remove the empty object inside exampleArray
and return the rest of the array.
I already tried to use filter
const noEmptyObjects = exampleNest.filter(({ exampleArray }) =>
exampleArray.filter(attachment => attachment !== {}),
);
i tried too Object.keys(attachment).length !== 0
instead of attachment !== {}
but i continue to receive the array with the empty item.