Returns the index of the last occurrence of value in an array, or -1 if it is not present (official Underscore docs). Stable Array helper — not deprecated.
Pass the required arguments shown below. Underscore array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.lastIndexOf. Start with this line.
Underscore
_.lastIndexOf(array, value, [fromIndex])
Call
What it does
_.lastIndexOf(array, value, [fromIndex])
Primary signature.
_.lastIndexOf(...)
Call with the arguments your case needs.
Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.
Library declarations
Underscore
_.lastIndexOf(array, value, [fromIndex])
Parameters
Parameter
Description
array
Required. List to search
value
Required. Value to find (===)
fromIndex
Optional. Start index for the backward scan
Return Value
Return Value
Description
*
Last matching index, or -1
Underscore.js Examples
Example 1 — Official: Last Occurrence
Find the last index of a repeated value — same call as the docs.
Forward helper._.indexOf returns the first hit → 1.
Backward helper._.lastIndexOf returns the last hit → 3.
Pick by intent. Need “most recent” or “final separator”? Prefer lastIndexOf.
Compatibility
Browser & Runtime Support
_.lastIndexOf 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
_.lastIndexOf()
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
_.lastIndexOfUnderscore 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]). Native Array.prototype.lastIndexOf is an ES5 baseline alternative without Underscore.
Frequently Asked Questions
_.lastIndexOf(array, value) returns the last index where value appears, searching backward with strict ===. If the value is missing, it returns -1.
_.indexOf scans from the start and returns the first match. _.lastIndexOf scans from the end and returns the last match. Both use ===.
Pass a number as the third argument to start searching backward at that index (same idea as Array.prototype.lastIndexOf).
It returns -1. Check with if (_.lastIndexOf(list, value) !== -1) for membership.
Strict equality (===). So 1 and '1' differ, NaN never matches NaN, and objects match only by reference.
Use _.findLastIndex when you need a predicate (function test), not a fixed value. Use _.lastIndexOf for a plain === value search.