Function property

  • Creates a function that returns the value at path of a given object.

    Parameters

    • path: PropertyPath

      The path of the property to get.

    Returns ((object: any) => any)

    Returns the new accessor function.

      • (object): any
      • Parameters

        • object: any

        Returns any

    2.4.0

    const objects = [
    { 'a': { 'b': 2 } },
    { 'a': { 'b': 1 } }
    ]

    map(objects, property('a.b'))
    // => [2, 1]

    map(sortBy(objects, property(['a', 'b'])), 'a.b')
    // => [1, 2]