When working with arrays in JavaScript, one of the cleanest and most efficient ways to check if a value exists is by using the some() method.


✅ What is some()?

  • some() is an array method that takes a callback function.
  • It returns:
    • true if at least one element satisfies the condition.
    • false if no elements match.
  • It stops iterating as soon as a match is found (great for performance).

Example:

const arr = ['a', 'b', 'c'];
const check = arr.some(x => x === 'z');
// Output: false