Lodash inRange method
语法
_.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.
参数
number (number) − The number to check.
[start=0] (number) − The start of the range.
end (number) − The end of the range.
输出
(boolean) − Returns true if number is in the range, else false.
实例
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
输出