Checks if n is between start and up to, but not including, end — a half-open interval [start, end). Part of Lodash Number (stable since 3.3.0 — not deprecated). If end is omitted, it becomes the second argument and start defaults to 0. If start > end, the params are swapped.
Pass the numbers shown below. Check bounds and return type before you use the result.
Syntax
Call _.inRange. Start with this line.
Lodash
_.inRange(number, [start=0], end)
Call
What it does
_.inRange(number, [start=0], end)
Primary signature.
Prefer import inRange from "lodash/inRange" when you want a smaller bundle.
Library declarations
Lodash
_.inRange(number, [start=0], end)
Parameters
Parameter
Description
number
Required. Value to check
start
Optional. Inclusive start (default 0 in two-arg form)
_.inRange is a Lodash Number helper available since 3.3.0. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native equivalents use a comparison like start <= n && n < end (after handling defaults and swaps yourself).
✓ Stable · Lodash 4.x
_.inRange()
Available in [email protected] full builds and the lodash/inRange modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.inRangeSince 3.3.0
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import inRange from "lodash/inRange" for smaller builds. Remember: end is exclusive.
Frequently Asked Questions
_.inRange(number, start, end) returns true when number is between start and up to, but not including, end. Official: _.inRange(3, 2, 4) → true.
Exclusive. After any swap, the test is start <= number < end — like array.slice(start, end).
If end is omitted, Lodash sets end to the second argument and start to 0. So _.inRange(4, 8) checks 0 <= 4 < 8 → true.
Lodash swaps them to support negative ranges. Official: _.inRange(-3, -2, -6) → true after treating the interval as [-6, -2).
inRange returns a boolean membership test on a half-open interval. clamp returns a number forced into inclusive bounds and does not auto-swap reversed bounds.
Use import inRange from "lodash/inRange" or require("lodash/inRange") so bundlers can tree-shake. Full build: import _ from "lodash" then _.inRange.