What you'll be able to do

By the end of this page you should be able to answer three common list questions with clear booleans: any item matches (some), all items match (every), and is this value in the list (includes) — without swapping the meanings.

Previous post: filter, find, findIndex.

Who this is for

  • People who write filter(...).length > 0 only to ask “is there any?”
  • Beginners who confuse some with every
  • Anyone who uses indexOf !== -1 everywhere and wants the clearer includes

You can skip this if those three methods already feel automatic. Come back when a validation bug treats “some valid” as “all valid.”

some: is there at least one match?

some returns true as soon as one item passes the test. Otherwise false.

const scores = [3, 5, 9];
const hasPass = scores.some(function (score) {
  return score >= 7;
});
console.log(hasPass); // true

Scenario A — disable Submit until any field is filled. fields.some((f) => f.trim().length > 0).

Scenario B — “does this cart have a sold-out item?” One match is enough to warn.

Empty array: [].some(...) is false (no item succeeded).

every: do all items match?

every returns true only if every item passes. One failure → false.

const scores = [8, 9, 10];
const allPass = scores.every(function (score) {
  return score >= 7;
});
console.log(allPass); // true

Scenario A — enable “Publish all” only when every draft has a title.

Scenario B — all tags non-empty. tags.every((t) => t.trim().length > 0).

Empty array: [].every(...) is true in JavaScript (vacuous truth). That surprises people — know it before using every on lists that might be empty.

includes: is this value present?

includes checks for a value with SameValueZero equality (handy for numbers; works well for strings and primitives).

const tags = ["javascript", "tutorials"];
console.log(tags.includes("javascript")); // true
console.log(tags.includes("python")); // false

Scenario A — feature flag list. allowed.includes(role).

Scenario B — avoid duplicate tags before push. if (!tags.includes(next)) tags.push(next).

includes does not take a callback. For “any item matching a condition,” use some. For objects, includes checks the same reference — two different { id: 1 } objects are not “included” just because fields match.

Boolean mix-ups to avoid

QuestionMethod
Any match?some
All match?every
Exact value in list?includes
First matching item?find (previous post)

Scenario A — wrong: every when you meant some. “Is anyone admin?” is some, not every.

Scenario B — wrong: includes with a function. Use some for conditions.

Tiny comparison with filter

const nums = [1, 2, 3];
nums.filter((n) => n > 10).length > 0; // works, builds an array
nums.some((n) => n > 10); // clearer yes/no

Scenario A — hot path / large lists. some can stop early; filter always builds the keepers.

Scenario B — you need the keepers anyway. Then filter is the right tool; don’t replace it with some.

A tiny practice file

Save as some-every.html.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>some every includes</title>
  </head>
  <body>
    <button id="go">Check [4, 8, 6]</button>
    <pre id="out"></pre>
    <script>
      const scores = [4, 8, 6];
      document.getElementById("go").addEventListener("click", function () {
        const somePass = scores.some(function (s) {
          return s >= 7;
        });
        const allPass = scores.every(function (s) {
          return s >= 7;
        });
        const hasEight = scores.includes(8);
        document.getElementById("out").textContent =
          "some >= 7: " + somePass + "\n" +
          "every >= 7: " + allPass + "\n" +
          "includes 8: " + hasEight;
      });
    </script>
  </body>
</html>

You should see some true, every false, includes true.

Mistakes I see a lot

1. Swapping some and every. Read the question out loud first.

2. Forgetting empty-array every is true. Guard empty lists when that matters.

3. Using includes for object shape checks. Use some((x) => x.id === id).

4. filter().length only to get a boolean. Prefer some.

5. Assuming includes deep-compares objects. It does not.

6. Negating the wrong method. “None match” is !arr.some(...), not arr.every with a confused test.

What to try before the next post

  1. some for any even number.
  2. every for all positive numbers; try [] too.
  3. includes on a tag list before pushing.
  4. Build the tiny HTML file.

Next in this series: reduce from zero — fold a list into one value without the intimidation.

Try this next outside the series

Arrays get easier when you see them render UI lists and move through real transforms.