May 09, 2021 CoffeeScript
You want to define the range of an array.
In CoffeeScript, there are two ways to define the range of array elements.
myArray = [1..10]
# => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
myArray = [1...10]
# => [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
To reverse the scope of an element, you can write it as below.
myLargeArray = [10..1]
# => [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]
myLargeArray = [10...1]
# => [ 10, 9, 8, 7, 6, 5, 4, 3, 2 ]
Contains scope with ".." T he operator definition, which contains the last value. E xclusion to "..." Operator definition, and the last value is usually ignored.