Skip to main content

times

_.times(iteratee, n) # Ⓢ [Ⓣ][1] Ⓝ

Invokes the iteratee n times, returning an array of the results of



each invocation. The iteratee is invoked with one argument; (index).

Since​

0.1.0

Arguments​

  1. iteratee (Function): The function invoked per iteration.
  2. n (number): The number of times to invoke iteratee.

Returns​

(Array): Returns the array of results.

Example​

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

_.times(_.constant(0), 4);
// => [0, 0, 0, 0]