Underscore.js _.iterators.range() Method
With the help of _.iterators.range() method, we can get the iterator function that gives the value within a given range which is specified into arguments and got incremented whenever invoked by using this method.
_.iterators.range(from, to, by)
Parameter: This method accepts three parameter as mentioned above and described below:
- from: This parameter holds the starting value of the range.
- to: This parameter holds the ending value of the range.
- by: This parameter holds the gap between to continues value in the range.
Return: Return the value within a given range.
Note: To execute the below examples you have to install the underscore-contrib library by using this command prompt we have to execute the following command.
npm install underscore-contrib
Example 1: In this example, we can see that by using _.iterators.range() method, we are able to get the values from iterator function who given the incremented value every time whenever invoked.
15 20 25 30 35...
5 7 9...