pick
pick<
T>(params):Record<string,unknown>
Defined in: objects/pick/index.ts:68
Creates an object with only the specified keys.
Type Parameters
Section titled “Type Parameters”T extends Record<string, unknown>
Parameters
Section titled “Parameters”params
Section titled “params”PickParams<T>
The parameters object
Returns
Section titled “Returns”Record<string, unknown>
A new object containing only the specified keys
Example
Section titled “Example”pick({ obj: { a: 1, b: 2, c: 3 }, keys: ["a", "c"] });// => { a: 1, c: 3 }Keywords
Section titled “Keywords”select keys, extract properties, subset object, pluck
Throws
Section titled “Throws”Error if obj is not an object
Throws
Section titled “Throws”Error if keys is not an array