goldies
    Preparing search index...

    Function pick

    • Creates a new object composed of properties picked from another object.

      Type Parameters

      • T extends object
      • K extends string | number | symbol

      Parameters

      • obj: T

        The object to pick properties from.

      • props: K[]

        An array of property names to use.

      Returns Pick<T, K>

      The new object.

      const sourceObj = {
      a: 1,
      b: 2,
      c: 3
      }

      const pickedObj = pick(sourceObj, ['a', 'c'])

      // pickedObj is now { a: 1, c: 3 }