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

    Parameters

    • n: number

      The number of times to invoke iteratee.

    • iteratee: ((num: number) => T)

      The function invoked per iteration.

        • (num): T
        • Parameters

          • num: number

          Returns T

    Returns T[]

    Returns the array of results.

    0.1.0

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

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