Function times

  • Invokes the iteratee n times, returning an array of the results of each invocation. The iteratee is invoked with one argument: (index).

    Type Parameters

    • T extends ((...args: any[]) => any)

    Parameters

    • n: number

      The number of times to invoke iteratee.

    • Optionaliteratee: T

      The function invoked per iteration.

    Returns ReturnType<T>

    Returns the array of results.

    5.0.0

    times(3, String)
    // => ['0', '1', '2']

    times(4, () => 0)
    // => [0, 0, 0, 0]