Pair. Use both when you need start and end without slicing.
All but last. Prefer _.initial when you need everything except the tail.
Compatibility
Browser & Runtime Support
_.last is a long-standing Lodash 4.x Array helper. It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.x
_.last()
Available in [email protected] full builds and the lodash/last 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
_.lastLodash 4.x
Bottom line: Safe for production once Lodash 4.x is on the page or in your bundle. Prefer import last from "lodash/last" for smaller builds. For the first element, use _.head.
Frequently Asked Questions
_.last(array) returns the last element of array. For an empty array it returns undefined. It does not change the array.
No. It only reads the final slot (length minus one for ordinary arrays) and returns that element.
undefined. Lodash does not throw when the collection has no last slot.
For a non-empty dense array they agree on the final element. _.nth supports arbitrary indexes (including other negative offsets); use _.last when you only need the tail element.
_.head reads index 0; _.last reads the final index. Same empty-array behavior (undefined).
Use import last from "lodash/last" or require("lodash/last") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.last.