JavaScript Array findLastIndex() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

Array.prototype.findLastIndex(callback) returns the index of the last element that passes your test. It scans from the end toward the start (ES2023). No match → -1. It does not mutate the array.

Remember
array.findLastIndex(callback)

scans: last → first
match → that index
no match → -1

findIndex() → first match index
findLast()  → last match value (not index)

Syntax

Call array.findLastIndex. Start with this line.

JavaScript
array.findLastIndex(callback, thisArg?)
CallWhat it does
array.findLastIndex(callback, thisArg?)Primary signature.
array.findLastIndex(...)Call with the arguments your case needs.

Built into JavaScript. Call findLastIndex(...) on an array instance — no import required.

Library declarations
JavaScript
array.findLastIndex(callback, thisArg?)

Parameters

ParameterDescription
ArrayRequired. Source to search
callbackRequired. Return truthy for a match
thisArgOptional. Optional this for the callback

Return Value

Return ValueDescription
*Index number, or -1

JavaScript Examples

Example 1 — Last Matching Index

Find the index of the last even number.

JavaScript
const numbers = [1, 2, 3, 4, 5, 2];

const lastEven = numbers.findLastIndex((n) => n % 2 === 0);

console.log(lastEven);  // 5
Try It Yourself

How It Works

  1. Build the array. Two even values sit at indexes 1 and 5.
  2. Scan from the end. The callback tests n % 2 === 0.
  3. First hit from the end. Index 5 is even → return immediately.
  4. No mutation. numbers stays unchanged; you only get an index.

Example 2 — No Match Returns -1

Always check for -1 before using the result as an index.

JavaScript
const numbers = [1, 3, 5];

const idx = numbers.findLastIndex((n) => n % 2 === 0);

console.log(idx);  // -1

if (idx === -1) {
  console.log("No even number");
}
Try It Yourself

How It Works

  1. All odd. Every callback call returns false.
  2. Sentinel. When the scan finishes with no hit → -1.
  3. Guard the result. Compare to -1 before reading or writing arr[idx].
  4. Same pattern as findIndex. Failed searches use -1, not undefined.

Example 3 — findLastIndex() vs findIndex()

Same test, different direction: first match vs last match.

JavaScript
const numbers = [1, 2, 3, 4, 5, 2];
const isTwo = (n) => n === 2;

console.log(numbers.findIndex(isTwo));      // 1
console.log(numbers.findLastIndex(isTwo));  // 5
Try It Yourself

How It Works

  1. Shared test. Both look for n === 2.
  2. findIndex. Scans from the start → first 2 at index 1.
  3. findLastIndex. Scans from the end → last 2 at index 5.
  4. Pick by goal. First hit → findIndex; last hit → findLastIndex.

Browser & Runtime Support

Array.prototype.findLastIndex() is part of ES2023. Evergreen browsers shipped it around 2022; Node.js includes it from version 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.

92% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Array.findLastIndex() Excellent

Bottom line: Safe for modern web apps and current Node LTS releases. For older targets, feature-detect with if ("findLastIndex" in Array.prototype) and fall back to a reverse loop or a polyfill.

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.

Next: flat()

Learn how to flatten nested arrays into a single level.

flat() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful