Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 762 Bytes

filterNonNull.md

File metadata and controls

30 lines (23 loc) · 762 Bytes

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.

Arguments:

  • object: An object which can contain null or undefined values.

Usage:

filterNonNull({
  firstName: "Oliver",
  lastName: null,
  phoneNumbers: { home: undefined, office: "1234567890" },
});

/*
{
  firstName: "Oliver",
  phoneNumbers: { office: "1234567890" },
}
*/