Object.pick

Object.pick

Object.pick

Function

Selects a field by key name and returns a new object.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
keysArray/StringNo[]An array of keys to retain, or multiple key parameters.

Return value

TypeDescription
ObjectReturns a new object containing only the specified keys.

Return object fields

The returned object contains only the fields hit by the passed key. The field value comes from the original object; the missed key will not be written to the returned object, and the read result is empty.

Example

Notes

  • pick does not modify the original object.
  • The returned objects are written in the order of the passed keys.