filterNonNull (source code)
- Curried: false
- Failsafe status: alternative available
The filterNonNull
function accepts an object and returns a new object with
only the properties that are not null
or undefined
. It filters out
properties with these values, creating a new object with only the non-null and
non-undefined properties.
object
: An object which can containnull
orundefined
values.
filterNonNull({
firstName: "Oliver",
lastName: null,
phoneNumbers: { home: undefined, office: "1234567890" },
});
/*
{
firstName: "Oliver",
phoneNumbers: { office: "1234567890" },
}
*/