I have many javascript objects which are like:
{
"id": "123",
"name": undefined,
"other": undefined,
"and": "so on",
... and many others, each time different fields
}
But most of the time the fields can be all undefined
except id
(which is always != undefined
).
I would like a method to detect if an object has AT LEAST ONE valued prop BESIDES "id".
What do you recommend?
2
Answers
you can use
Object.entries
andsome
We can use for in loop. In the loop we put condition that key can’t be id and other keys cannot be undefined. For Example :