The some() method check if some array values pass a test.

This example check if some array values are larger than 18:

Example

const numbers = [45, 4, 9, 16, 25];
let someOver18 = numbers.some(myFunction);

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

Note that the function takes 3 arguments:

  • The item value
  • The item index
  • The array itself

Array.some() is supported in all browsers except Internet Explorer 8 or earlier.



Practice Excercise Practice now