JavaScript array.findLastIndex() Function

JavaScript Logo

array.findLastIndex() – ES2022: Returns the **last index** where the testing function returns true or `-1`.

๐Ÿ‘‰ Syntax

index = array.findLastIndex(callbackFn[, thisArg]);

๐Ÿงช Example

const nums=[3,5,7,10,7];
console.log(nums.findLastIndex(n => n < 8)); // 4

Comments