_.size ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.
✓ Stable · Underscore 1.x
_.size()
Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.
100%With Underscore 1.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
_.sizeUnderscore 1.x+
Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).
Frequently Asked Questions
_.size(list) returns the number of values in the list. Official examples: _.size([1, 2, 3, 4, 5]) → 5 and _.size({one: 1, two: 2, three: 3}) → 3.
For arrays and strings, _.size is the same as .length. For plain objects (no .length), _.size counts own enumerable keys — one helper for every collection type.
It counts own enumerable keys — the same set _.keys returns. Inherited properties are not included.
_.size(null) and _.size(undefined) return 0. Empty arrays, objects, and strings also return 0.
Yes. Array-like values are measured by their length, so you get the element count directly.