主题
times
js
_.times(n, [iteratee=_.identity])
调用 iteratee n
次,返回每次调用结果的数组。迭代器使用一个参数调用;(index)。
¥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
n
(数值):调用iteratee
的次数。¥
n
(number): The number of times to invokeiteratee
.[iteratee=_.identity]
(函数):每次迭代调用的函数。¥
[iteratee=_.identity]
(Function): The function invoked per iteration.
返回
¥Returns
(数组):返回结果的数组。
¥(Array): Returns the array of results.
示例
¥Example
js
_.times(3, String);
// => ['0', '1', '2']
_.times(4, _.constant(0));
// => [0, 0, 0, 0]