Pick specific properties from an object.
This function creates a new object composed of the properties listed in the keys array, extracted from the source object.
keys
source
const obj = { a: 1, b: 2, c: 3 };const result = pickObjectProps(obj, ['a', 'c']);// => { a: 1, c: 3 }
const user = { name: 'John', age: 30, email: 'john@example.com' };const picked = pickObjectProps(user, ['name', 'email']);// => { name: 'John', email: 'john@example.com' }
The source object from which to pick properties.
An array of keys that should be picked from the source object.
Pick specific properties from an object.
This function creates a new object composed of the properties listed in the
keys
array, extracted from thesource
object.Example
Example