Skip to content

JavaScript Tutorial Arrays

JavaScript Array some() and every()

Lesson 67 of 258 2 min read By Deepak Paswan Updated Oct 4, 2026

Two methods answer yes/no questions about a whole array. Both take a callback that returns true or false for each item.

some: is there at least one?

script.js
JS
const prices = [12, 8, 45, 20];

console.log(prices.some(price => price > 40)); // → true
console.log(prices.some(price => price > 100)); // → false

some returns true as soon as one item passes, and stops looking.

every: do all of them pass?

script.js
JS
const ages = [21, 34, 19, 52];

console.log(ages.every(age => age >= 18)); // → true
console.log(ages.every(age => age >= 20)); // → false

every returns false as soon as one item fails.

Empty arrays

script.js
JS
console.log([].some(x => x > 0));  // → false
console.log([].every(x => x > 0)); // → true

An empty array has no item that passes (some is false) and no item that fails (every is true). Keep this in mind when an empty list should block something.

Real examples

script.js
JS
const cart = [
  { name: "Book", inStock: true },
  { name: "Pen", inStock: false }
];

const canCheckout = cart.every(item => item.inStock);
const hasOutOfStock = cart.some(item => !item.inStock);

console.log(canCheckout);    // → false
console.log(hasOutOfStock);  // → true

A form check:

script.js
JS
const fields = [
  { name: "email", value: "maya@example.com" },
  { name: "name", value: "" }
];

const allFilled = fields.every(field => field.value.trim() !== "");
console.log(allFilled); // → false

Instead of a loop with a flag

Without these methods, you would write a loop and a variable:

script.js
JS
let found = false;
for (const price of prices) {
  if (price > 40) { found = true; break; }
}

prices.some(price => price > 40) says the same in one line, and it reads like a question.

info
Related methods
find returns the matching item, filter returns all matching items, some and every return a yes or no. See Searching Arrays and filter().