Ceiling.MAX_SAFE_INTEGER is the inclusive upper bound.
Past safe. One larger fails even if it “looks” whole in math.
Negatives.-1 is an integer but never a length.
Compatibility
Browser & Runtime Support
_.isLength is a Lodash Lang helper (available since 4.0.0, stable in 4.x). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.0.0+
_.isLength()
Available in [email protected] full builds and the lodash/isLength 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
_.isLengthLodash 4.0.0+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import isLength from "lodash/isLength" for smaller builds. Native alternative for a similar idea: Number.isSafeInteger(n) && n >= 0.
Frequently Asked Questions
_.isLength(value) returns true if value is a valid array-like length: a number that is non-negative, an integer, and ≤ Number.MAX_SAFE_INTEGER (9007199254740991).
No. _.isInteger allows negatives (for example -7). _.isLength only accepts values > -1 and also caps at MAX_SAFE_INTEGER.
The value must be a number type first. Numeric strings fail even if they look like lengths — parse with Number(...) or _.toNumber before checking.
Yes. 0 is a valid length for empty collections because the check is value > -1, not value > 0.
Both return false. Infinity is not finite; MIN_VALUE is a tiny positive float, not an integer length.
Use import isLength from "lodash/isLength" or require("lodash/isLength"). Full build: import _ from "lodash" then _.isLength.