_.times
语法:
_.times(n, [iteratee=_.identity])
源代码链接:source
npm包链接:npm package
描述:
调用 iterateen
次,每次调用返回的结果存入到数组中。 iteratee 调用入1个参数:(index)。
开始版本:0.1.0
参数:
n (number)
: 调用 iteratee 的次数。[iteratee=_.identity] (Function)
: 每次迭代调用的函数。
返回值:
(Array)
: 返回调用结果的数组。
例子:
_.times(3, String);
// => ['0', '1', '2']
_.times(4, _.constant(0));
// => [0, 0, 0, 0]
Last updated
Was this helpful?