Lodash rangeRight method
语法
_.rangeRight([start=0], end, [step=1])
This method is like _.range except that it populates values in descending order.
参数
[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.
输出
(Array) − Returns the range of numbers.
实例
var _ = require('lodash');
console.log(_.rangeRight(4));
console.log(_.rangeRight(0, 20, 5));
Save the above program in
tester.js. Run the following command to execute this program.
Command
输出
[ 3, 2, 1, 0 ]
[ 15, 10, 5, 0 ]