_.inRange

_.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.

Since

3.3.0

Arguments

  1. number (number): The number to check.
  2. [start=0] (number): The start of the range.
  3. end (number): The end of the range.

Returns

(boolean): Returns true if number is in the range, else false.

Example

_.inRange(3, 2, 4);
// => true
 
_.inRange(4, 8);
// => true
 
_.inRange(4, 2);
// => false
 
_.inRange(2, 2);
// => false
 
_.inRange(1.2, 2);
// => true
 
_.inRange(5.2, 4);
// => false
 
_.inRange(-3, -2, -6);
// => true
doc_Lodash
2016-11-27 16:37:36
Comments
Leave a Comment

Please login to continue.