Creates a new object composed of the enumerable own properties of source for which the predicate function returns a truthy value.
source
The type of the source object
The source object to pick from
A function (key, value) => boolean that is invoked for each own enumerable property. A property is included in the result when the predicate returns truthy.
(key, value) => boolean
A new object containing only the properties for which predicate returned truthy. Returns an empty object if source is null or undefined.
predicate
0.14.0
const obj = { a: 1, b: 2, c: 3, d: 4 };objPickBy(obj, (key, value) => value > 2); // { c: 3, d: 4 }objPickBy(obj, (key) => key !== "b"); // { a: 1, c: 3, d: 4 } Copy
const obj = { a: 1, b: 2, c: 3, d: 4 };objPickBy(obj, (key, value) => value > 2); // { c: 3, d: 4 }objPickBy(obj, (key) => key !== "b"); // { a: 1, c: 3, d: 4 }
Creates a new object composed of the enumerable own properties of
sourcefor which the predicate function returns a truthy value.