I want to check a javascript object to see if any of it’s properties are missing without checking each property individually.
I can use "hasownproperty" or do if/else statements to check if each one is null/undefined, I wanted a shorter way of checking an object.
2
Answers
Perhaps this?
Use
Array::some()
on object values (get them withObject.values()
) (this will returntrue
if ANY property’s value isnull
orundefined
):If you want it the fastest possible, write your own function:
And a benchmark: