Example 1 — Basic Membership Check
Ask whether a value exists — get a clear boolean.
const numbers = [1, 2, 3, 4, 5];
console.log(numbers.includes(3)); // true
console.log(numbers.includes(10)); // false How It Works
- Build the array. Numbers
1through5. - Look for 3. It is present →
true. - Look for 10. Not present →
false. - No index math. You do not need to compare with
-1.

