Check if any property of object has null value

Viewed 327

I have following array of objects data, that has multiple properties, some of them can have null value.

enter image description here

I want to filter through this array of objects and remove every object that has property of null value. So far I have tried this code, but with no luck:

const noNull = data.filter((doc) => { return Object.values(doc).some(prop => { if (prop !== null) return doc; } )});

Any ideas how can I achieve this?

Thank you in advance.

1 Answers

Here Updated to keep items which do not have a null value

const noNull = obj.filter((doc) => { return Object.values(doc).every(prop => prop !== null)})

.some() and .every() expect boolean return value

reference

Related