Function method

  • Creates a function that invokes the method at path of a given object. Any additional arguments are provided to the invoked method.

    Parameters

    • path: ArrayPath

      The path of the method to invoke.

    • Rest ...args: any[]

      The arguments to invoke the method with.

      Rest

    Returns any

    Returns the new invoker function.

    Since

    5.11.0

    Example

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

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

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