Object
/ API Reference
Object
/ API Reference

pick

Creates an object composed of the picked object properties.

The Gist

import { pick } from '@weser/object'

const obj = { a: 1, b: 2, c: 3 }
const picked = pick(obj, ['a', 'c'])

// => { a: 1, c: 3 }
console.log(picked)

Parameters

ParameterTypeDescription
objTThe source object.
keysArray<keyof T>The property names to pick.

Returns

(Pick<T, K>) Returns the new object with only the picked properties.

On this page