Skip to main content

pick

Callable

  • pick<T, K>(target: T, keys: K[]): Plain<Pick<T, K>>

  • Returns a new object with properties from the original object that are specified in the keys array.

    @example
    pick({ a: 1, b: '2' }, ['a']) // { a: 1 }

    Type parameters

    • T

      The type of the original object.

    • K: string | number | symbol

      The type of the keys of the original object to be picked.

    Parameters

    • target: T

      The original object to pick properties from.

    • keys: K[]

      An array of keys to pick from the original object.

    Returns Plain<Pick<T, K>>

    A new object with properties picked from the original object.