The start of the range.
Optional
end: numberThe end of the range.
Optional
Optional
step: numberThe value to increment or decrement by.
Optional
Returns the range of numbers.
5.7.0
[[inRange]],[[rangeRight]]
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)
// => []
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 negativestart
is specified without anend
orstep
. Ifend
is not specified, it's set tostart
, andstart
is then set to0
.Note: JavaScript follows the IEEE-754 standard for resolving floating-point values which can produce unexpected results.