Widely availableSupported across all major browsers. Safe to use in production.

Overview

The findLast() and findLastIndex() methods of arrays and typed arrays search an array in reverse order for the first item that satisfies a test function.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
97
97
104
15.4
97
15.4
Built-in object

The findLastIndex() method of Array instances iterates the array in reverse order and returns the index of the first element that satisfies the provided testing function. If no elements satisfy the testing function, -1 is returned.

97
97
104
15.4
97
15.4

The findLast() method of TypedArray instances iterates the typed array in reverse order and returns the value of the first element that satisfies the provided testing function. If no elements satisfy the testing function, undefined is returned. This method has the same algorithm as Array.prototype.findLast().

97
97
104
15.4
97
15.4

The findLastIndex() method of TypedArray instances iterates the typed array in reverse order and returns the index of the first element that satisfies the provided testing function. If no elements satisfy the testing function, -1 is returned. This method has the same algorithm as Array.prototype.findLastIndex().

97
97
104
15.4
97
15.4
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
const nums = [1, 2, 3, 4, 5, 4, 3];

nums.findLast(n => n > 3);      // 4 (the first occurrence from the end)
nums.findLastIndex(n => n > 3); // 5

Live demo

end from number Search

Array. after from show, first. even show..

PreviewFullscreen

end from object Search

specific. ste-tas haslast. aitemu specific..

PreviewFullscreen

end from. position(index)

condition to combineelement that after from number. position to exists or read..

PreviewFullscreen

Use cases

  • Using Array findLast() and findLastIndex()

    The findLast() and findLastIndex() methods of arrays and typed arrays search an array in reverse order for the first item that satisfies a test function.

Cautions

  • No specific concerns. Stable across all major browsers.

Accessibility

  • When updating the DOM dynamically, announce important changes to assistive technology with aria-live regions.

Powered by web-features