![Lodash Tutorial](/lodash/images/lodash-mini-logo.jpg)
- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - inRange method
Syntax
_.inRange(number, [start=0], end)
Checks if n is between start and up to, but not including, end. If end is not specified, it's set to start with start then set to 0. If start is greater than end the params are swapped to support negative ranges.
Arguments
number (number) − The number to check.
[start=0] (number) − The start of the range.
end (number) − The end of the range.
Output
(boolean) − Returns true if number is in the range, else false.
Example
var _ = require('lodash'); var result = _.inRange(-12, -22, 2); console.log(result); result = _.inRange(12, -22, 2); console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
true false
lodash_number.htm
Advertisements