从对象中选取指定的键,返回仅包含这些键的新对象
源对象的类型
要选取的键,必须是源对象的键之一
源对象
要选取的键名数组
仅包含指定键的新对象
const user = { id: 1, name: "Alice", age: 25, password: "secret"};// { id: 1, name: "Alice", age: 25 }const safeUser = pick(user, ["id", "name", "age"]); Copy
const user = { id: 1, name: "Alice", age: 25, password: "secret"};// { id: 1, name: "Alice", age: 25 }const safeUser = pick(user, ["id", "name", "age"]);
从对象中选取指定的键,返回仅包含这些键的新对象