Utilizor
Contact Us

find, findIndex

Searching arrays.

find and findIndex

find() returns the value of the first array element that passes a test function.

findIndex() returns the index of the first array element that passes a test function.

Example

const numbers = [4, 9, 16, 25, 29];
let first = numbers.find(myFunction);

function myFunction(value, index, array) {
  return value > 18;
}