@pengzhanbo/utils - v3.12.0
    Preparing search index...

    Function pick

    • Creates a new object composed of the picked object properties.

      创建一个由所选对象属性组成的新对象。

      Type Parameters

      • T extends Record<PropertyKey, any>

        The type of the source object / 源对象类型

      • K extends string | number | symbol = keyof T

      Parameters

      • obj: T

        The source object. 源对象

      • keys: readonly K[]

        The keys to pick. 要选择的键

      Returns Pick<T, K>

      A new object with only the picked properties. 仅包含所选属性的新对象

      An own __proto__ key is ignored, so untrusted input can neither replace the prototype of the result.

      源对象自有的 __proto__ 键会被忽略,避免不可信输入替换结果原型。

      pick({ a: 1, b: 2 }, ['a']) // => { a: 1 }