Tip. Negative starts still scan forward from that point.
Compatibility
Browser & Runtime Support
_.indexOf is a Lodash 4.x Array helper (available since early Lodash). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.
✓ Stable · Lodash 4.x
_.indexOf()
Available in [email protected] full builds and the lodash/indexOf 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
_.indexOfLodash 4.x+
Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import indexOf from "lodash/indexOf" for smaller builds. Native Array.prototype.indexOf is similar but cannot find NaN.
Frequently Asked Questions
_.indexOf(array, value, fromIndex) returns the index of the first occurrence of value in array using SameValueZero equality. If not found, it returns -1.
No. It only scans and returns a number. The source array is unchanged.
It is where the forward search starts (default 0). A negative fromIndex is treated as an offset from the end of the array.
indexOf matches one concrete value. findIndex runs a predicate function per element for custom logic.
Use import indexOf from "lodash/indexOf" or require("lodash/indexOf") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.indexOf.