Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 746 Bytes

findIndex.md

File metadata and controls

35 lines (23 loc) · 746 Bytes

arrays.findIndex

findIndex(array, predicate, [thisArg])

FindIndex method returns the value of First element at which a provided function is true, or -1 if no elements in the array satisfy the function.

Arguments

  1. array (Array): input array
  2. predicate (Function): to be run against each element of the array
  3. [thisArg] (*): this argument in the function

Returns

(*): value of element that satisfied function.

Example

const result = arrays.findIndex([5, 12, 8, 130, 44], (x) => x < 10);
console.log(result);
> 0