_.times

_.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

  1. n (number): The number of times to invoke iteratee.
  2. [iteratee=_.identity] (Function): The function invoked per iteration.

Returns

(Array): Returns the array of results.

Example

_.times(3, String);
// => ['0', '1', '2']
 
 _.times(4, _.constant(0));
// => [0, 0, 0, 0]
doc_Lodash
2016-11-27 16:41:09
Comments
Leave a Comment

Please login to continue.