omitBy
Creates a new object without the own enumerable entries for which
predicate returns true.
Complements omit for when the keys to remove aren’t known ahead of
time — omit takes an explicit key list, omitBy takes a predicate.
Available since v3.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
obj | T | null | undefined | The source object. `null`/`undefined` pass through unchanged. |
predicate | function | Called with `(value, key)` for each own enumerable entry |
Returns
Section titled “Returns”Partial<T> | null | undefined — A new object without the matching entries
Examples
Section titled “Examples”Drop entries matching a predicate
Section titled “Drop entries matching a predicate”Unlike omit(), the keys to drop don’t need to be known ahead of time.
Drop entries by key name
Section titled “Drop entries by key name”The predicate also receives the key, so filtering by name works too.
