Lodash - rangeRight method


Advertisements

Syntax

_.rangeRight([start=0], end, [step=1])

This method is like _.range except that it populates values in descending order.

Arguments

  • [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.

Output

  • (Array) − Returns the range of numbers.

Example

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

\>node tester.js

Output

[ 3, 2, 1, 0 ]
[ 15, 10, 5, 0 ]
lodash_util.htm
Advertisements