Function nthArg

  • Creates a function that gets the argument at index n. If n is negative, the nth argument from the end is returned.

    Parameters

    • n: number = 0

      The index of the argument to return.

    Returns typeof nth

    Returns the new pass-thru function.

    Since

    5.10.0

    Example

    const func = nthArg(1)
    func('a', 'b', 'c', 'd')
    // => 'b'

    const func = nthArg(-2)
    func('a', 'b', 'c', 'd')
    // => 'c'