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)

    Parameters

    • n: number

      The number of times to invoke iteratee.

    • Optional iteratee: T

      The function invoked per iteration.

      Optional

    Returns ReturnType<T>

    Returns the array of results.

    Since

    5.0.0

    Example

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

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