Typed Array findLast()
Example
// Create a Typed Array
const myArr = Int16Array.from([10,15,20,25,30,35,40,45,50]);
// Find last element with a value over 18
result = myArr.find(x => x > 18);
Try it Yourself »
Description
The findLast()
method returns the value of the last element that passes a test.
The findLast()
method executes a function for each array element.
The findLast()
method returns undefined
if no elements are found.
The findLast()
method does not execute the function for empty elements.
The findLast()
method does not change the original array.
Syntax
typed-array.findLast(function(currentValue, index, arr),thisValue)
typed-array must be one of the following: Int8ArrayUint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float16Array Float32Array Float64Array BigInt64Array BigUint64Array |
Parameters
function() | Required. A function to run for each array element. |
currentValue | Required. The value of the current element. |
index | Optional. The index of the current element. |
arr | Optional. The array of the current element. |
thisValue | Optional. Default undefined .A value passed to the function as its this value. |
Return Value
Type | Description |
A value |
The value of the last element that pass the test. Otherwise it returns undefined . |
Typed Array Find Methods:
Method | Finds |
---|---|
includes() | Returns true if an element is present in the array |
indexOf() | The index of the first element with a specified value |
lastIndexOf() | The index of the last element with a specified value |
find() | The value of the first element that passes a test |
findIndex() | The index of the first element that passes a test |
findLast() | The value of the last element that passes a test |
findLastIndex() | The index of the last element that passes a test |
JavaScript Typed Arrays
Browser Support
typed-array.findLast()
is an ES2023 feature.
JavaScript 2023 is supported in all modern browsers since July 2023:
Chrome 110 | Edge 110 | Firefox 115 | Safari 16.4 | Opera 96 |
Feb 2023 | Feb 2023 | Jul 2023 | Mar 2023 | May 2023 |