Is there anything similar to python reversed range in lodash.
In python
list(reversed(range(0, 4)))
=> [3, 2, 1, 0]
list(reversed(range(3, 4)))
=> [3]
in lodash
console.log(_.range(3,4,-1))
[]
console.log(_.range(0, 4, -1));
[]
You have the start and stop values reversed.
console.log(_.range(3, -1, -1));
# [ 3, 2, 1, 0 ]
Alternatively you can use the chainable reverse
function, with the range
, like this
console.log(_.range(0, 4).reverse());
# [ 3, 2, 1, 0 ]
Note: Neither of them is similar to Python 3.x's range
function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With