Favorites

JavaScript Array.prototype.findIndex() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Array.prototype.findIndex()
JavaScript Array Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The findIndex() method returns the index of the first element that passes a test, or -1 if no element does.

Description

The findIndex() method returns the index of the first element for which the callback returns a truthy value, or -1 if there is none. It is useful when you need to update or remove the element, for example with splice() or with().

Unlike indexOf(), which looks for an exact value, findIndex() takes a test function, so it can match objects by their properties.

Unlike most array methods, findIndex() calls the callback for empty slots in sparse arrays too, passing undefined. A common pattern is updating an item in place: find its index, then assign arr[i] = newItem, or use arr.with(i, newItem) for a copy. Always check for -1 first, because arr[-1] is just undefined and splice(-1, 1) would remove the last element.

Syntax

array.findIndex(callbackFn)
array.findIndex(callbackFn, thisArg)

Parameters

  • callbackFnA function called for each element, receiving element, index and array.
  • thisArgOptional. A value to use as this inside callbackFn.

Return Value

The index of the first element that passes the test, or -1 if none does.

Example

const people = [{ name: 'Sam' }, { name: 'Alex' }, { name: 'Lee' }];
const i = people.findIndex(p => p.name === 'Alex');
console.log(i);
console.log(people.findIndex(p => p.name === 'Zoe'));

Browser Support

The following information will show you the current browser support for the Array.prototype.findIndex() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee