从对象中选取满足条件的键值对,返回仅包含这些键的新对象
源对象的类型
源对象
判断函数,返回 true 时保留该字段
true
仅包含满足条件的键值对的新对象
const user = { id: 1, name: "Alice", age: 25, password: "secret"};// { id: 1, age: 25 }const numericFields = pickBy(user, (key, value) => typeof value === "number"); Copy
const user = { id: 1, name: "Alice", age: 25, password: "secret"};// { id: 1, age: 25 }const numericFields = pickBy(user, (key, value) => typeof value === "number");
从对象中选取满足条件的键值对,返回仅包含这些键的新对象