»Builtin Function: range
The built-in function
range returns a list of numbers in a range.
There are three ways to call this function:
range(end)range(start, end)range(start, end, step)
start is inclusive, the
end is exclusive.
start is not provided, it defaults to
step is not provided, it
Negative steps are permitted and count down from
The range ends when the next value given by the sum of the last value and
end, regardless of if it has been reached.
range(5) // [0,1,2,3,4]range(1, 5) // [1,2,3,4] - starts at 1 instead of 0range(1, 5, 2) // [1,3] - 3+2 does not satisfy r[-1] < endrange(0, -3, -1) // [0,-1,-2] - example of negative range
Impossible ranges, or ranges where
start will never reach
yield an empty list.
range(1, 1) //  - already starting at 1range(0, 1, -1) //  - negative step will never reach 1
Supplying an undefined value to any argument of
range yields an undefined
A range with a zero step is a runtime error.