36

some() - if it finds an array element, the function returns a true and does not check the remaining values.

while...

includes() - for all elements in the array does a generic compare and return true if it finds the match or at the first match?

When to use some and when includes?

Dijkgraaf
  • 11,049
  • 17
  • 42
  • 54

1 Answers1

71

some takes in a callback function where you can write your own logic to determine if an array contains some element which matches the conditions you wrote.

includes does a generic equalTo comparison on every element and will return true if at least one element in the array is equal to the value to find.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83