Oversized n. You get the whole array (no padding).
Compatibility
Browser & Runtime Support
_.first (and aliases _.head / _.take) 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
_.first()
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
_.firstUnderscore 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
_.first(array) returns the first element. Pass a count with _.first(array, n) to get the first n elements as a new array.
_.head and _.take are aliases — same function, same behavior. Pick the name that reads best in your code.
Without n, _.first([]) returns undefined. With n, such as _.first([], 2), it returns [].
No. It only reads. The n-form returns a new array; the source is unchanged.
For one element they match on a non-empty array. _.first also supports the n-form and returns undefined (not an error) for an empty array without n.
_.first reads from the start; _.last reads from the end. Both support an optional n count.