let x = {
"name": undefined,
"value": "tr",
"prop1": undefined,
"prop2": "test",
"prop3": 123
};
I need to find the number of properties that are undefined, so in this case 2.
With regular JS:
Good comments pointed out that we can indeed immediately filter; more efficient:
Object.values(x).filter(v=> v === undefined).length
With Lodash
_.filter(x, (v, k) => v === undefined).length