I have an object and I want to remove all properties that have a value of null
, but I want to keep a special property which is alwaysCountWithMe
(even if its value is null). My code looks like this:
var object = {
"firstname": null,
"lastname": "White",
"hobby": null,
"c": 3 ,
"alwaysCountWithMe": null
};
console.log(_.pickBy(object, value => !!value));
This prints:
{"lastname": "White", "c": 3}
But I want it to print:
{"lastname": "White", "c": 3, "alwaysCountWithMe": null }