Returns the index at which value can be found in the array, or -1 if it is not present (official Underscore docs). Optional third argument: true for sorted binary search, or a from-index number.
Pass the required arguments shown below. Underscore array helpers usually return a new value — check whether the source array is mutated.
Syntax
Call _.indexOf. Start with this line.
Underscore
_.indexOf(array, value, [isSorted])
Call
What it does
_.indexOf(array, value, [isSorted])
Primary signature.
_.indexOf(...)
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
_.indexOf(array, value, [isSorted])
Parameters
Parameter
Description
array
Required. List to search
value
Required. Target to find (strict ===)
isSorted / fromIndex
Optional. true = binary search; number = start index
true. Underscore uses binary search (and <), not a full linear scan.
Hit.40 is at index 3.
Warning. If the array is not sorted, results can be wrong — only pass true when order is guaranteed.
Compatibility
Browser & Runtime Support
_.indexOf ships with Underscore.js (1.x), including sorted binary search and fromIndex. It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore. Native Array.prototype.indexOf is separate and has no isSorted flag.
✓ Stable · Underscore 1.x
_.indexOf()
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
_.indexOfUnderscore 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
_.indexOf(array, value, [isSorted]) returns the first index where value is found, or -1 if it is missing. Comparison uses strict === (with special NaN handling).
Pass true to binary-search a sorted array (faster on large sorted lists). Pass a number to start the linear search at that index (fromIndex).
It returns -1. Check with if (index !== -1) before using the index.
_.indexOf looks for a fixed value with ===. _.findIndex runs a predicate function and returns the first index that passes the test.
_.indexOf finds the first match from the start. _.lastIndexOf finds the last match from the end.