Tweakr
    Preparing search index...

    Function pick

    • Returns a new object containing only the specified keys.

      Type Parameters

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

      Parameters

      • obj: T

        The source object.

      • keys: K[]

        An array of keys to include in the new object.

      Returns Pick<T, K>

      A new object with only the specified keys.

      const obj = { a: 1, b: 2, c: 3 };
      const result = pick(obj, ["a", "c"]);
      console.log(result); // { a: 1, c: 3 }

      1.1.0