4.17.11
3.10.1
2.4.2
1.3.1

_.times(n, [iteratee=_.identity])

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

argument
n
[iteratee=_.identity]
type
number
Function
description
The number of times to invoke `iteratee`.
The function invoked per iteration.

Returns

(array)

Example

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

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

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