Function prop

Returns the specified property of an object.

prop('name')({ name: 'John', surname: 'Doe' }) // 'John'
prop('age')({ name: 'John', surname: 'Doe' } as Record<string, string>) // undefined
  • Type Parameters

    • K extends string

    Parameters

    • key: K

    Returns (<O>(obj: O) => O[K])