_.range([start=0], end, [step=1])
Creates an array of numbers (positive and/or negative) progressing from start
up to, but not including, end
. A step of -1
is used if a negative start
is specified without an end
or step
. If end
is not specified, it's set to start
with start
then set to 0
.Note: JavaScript follows the IEEE-754 standard for resolving floating-point values which can produce unexpected results.
Since
0.1.0
Arguments
[start=0]
(number): The start of the range.end
(number): The end of the range.[step=1]
(number): The value to increment or decrement by.
Returns
(Array): Returns the range of numbers.
Example
_.range(4);// => [0, 1, 2, 3]_.range(-4);// => [0, -1, -2, -3]_.range(1, 5);// => [1, 2, 3, 4]_.range(0, 20, 5);// => [0, 5, 10, 15]_.range(0, -4, -1);// => [0, -1, -2, -3]_.range(1, 4, 0);// => [1, 1, 1]_.range(0);// => []
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .