I have a data object that looks like this:
var obj = {
"one": null,
"two": undefined,
"three": [undefined],
"four": "valid value"
}
And I need to end up with this:
{
"four": "valid value"
}
I'm using lodash to try and accomplish this, and it's gotten me part way there:
obj = _.pick(obj, _identity);
Which gives me:
{
"three": [undefined],
"four": "valid value"
}
Is there a lodash-centric way to also remove not only keys whose values are null or undefined and also remove keys whose values are arrays that contain only undefined or null? I know there's a bunch of ways to do this in general, I was just wondering if lodash had some way to do this baked in.