The findLastIndex() method returns the index of the last element that passes your test, searching from the end. If nothing matches, it returns -1. This ES2023 tutorial covers syntax, five examples, comparisons with findIndex() and findLast(), and practical update/remove patterns.
01
Syntax
findLastIndex(cb)
02
Last index
Tail-first
03
No match
-1
04
vs findIndex
End vs start
05
Splice ready
Update/remove
06
ES2023
Modern JS
Fundamentals
Introduction
findLast() tells you what matched at the tail. findLastIndex() tells you where it matched—so you can remove it, replace it, or scroll a list to that row.
It is the tail-first partner of findIndex(), added in ES2023 alongside findLast().
Concept
Understanding the findLastIndex() Method
array.findLastIndex(callback) invokes your callback starting at the last index and moving toward 0. The first truthy result returns that index immediately.
If every callback is falsy, the result is -1.
💡
Beginner Tip
Compare with index !== -1, not truthiness—index 0 is valid but falsy in an if (index) check.
Only the last "js" at index 3 is removed; the first "js" at index 0 remains.
Applications
🚀 Common Use Cases
Remove last duplicate — splice the final matching tag or category.
Update trailing record — replace the most recent matching row.
Deduplication — keep first occurrence via findLastIndex in filters.
Log analysis — index of the latest error for detail panels.
Form arrays — focus the last invalid field in a list.
Undo stacks — find the last reversible action marker.
🧠 How findLastIndex() Runs
1
Start at length - 1
Evaluate from the last index backward.
Tail
2
Run callback
Pass (element, index, array) each step.
Test
3
Truthy?
Return that index and stop.
Match
4
🔢
Index 0 checked
If nothing passed, return -1.
Important
📝 Notes
ES2023—pair with feature detection or polyfills for old browsers.
Returns -1 on failure, not undefined.
Index 0 is valid; use index !== -1 for found checks.
For primitive equality only, lastIndexOf may suffice.
Short-circuits at the first match from the tail.
Works on typed arrays with the same signature.
Compatibility
Browser & Runtime Support
Array.prototype.findLastIndex() was added in ES2023 together with findLast(). It is available in current evergreen browsers and Node.js 18+.
✓ Baseline · ES2023
Array.prototype.findLastIndex()
Supported in Chrome 97+, Firefox 104+, Safari 15.4+, Edge 97+, and Node 18+. Not available in Internet Explorer or very old mobile browsers.
92%Modern browser support
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
Array.findLastIndex()Very Good
Bottom line: Safe for modern apps on current browser versions. Polyfill or backward for-loop when older clients must be supported.
Wrap Up
Conclusion
The findLastIndex() method closes the tail-search loop: you get a numeric slot for the last match, ready for splice, assignment, or UI focus—without reversing the array.
Combine it with findLast() when you need the value, and with findIndex() when the first match is what matters.
Five things to remember about Array.findLastIndex()
Your foundation for tail-first index searches in ES2023.
5
Core concepts
📝01
Syntax
arr.findLastIndex(cb)
API
🔃02
Tail-first
End → start.
Direction
🔢03
Returns index
Number.
Position
❌04
No match
-1
Sentinel
📅05
ES2023
With findLast.
Standard
❓ Frequently Asked Questions
findLastIndex() returns the index of the last element for which the callback returns a truthy value. It searches from the end of the array toward the start. If no element matches, it returns -1.
No. findLastIndex() only reads elements through your callback. The original array is unchanged unless you mutate it afterward using the returned index.
It returns -1, the same sentinel used by findIndex, indexOf, and lastIndexOf when a search fails.
findLastIndex() returns the numeric index (or -1). findLast() returns the matching element itself (or undefined). Use findLastIndex when you need to splice, assign, or focus a UI row by position.
findIndex() scans from the start and returns the first match index. findLastIndex() scans from the end and returns the last match index.
findLastIndex() is an ES2023 feature. It works in Chrome 97+, Firefox 104+, Safari 15.4+, Edge 97+, and Node 18+. Older environments need a polyfill or a backward loop.
Did you know?
Before ES2023, getting the last matching index often meant arr.map((v,i)=>i).reverse().find(...) or a manual backward loop. findLastIndex() does the same in one readable call.