JavaScript Array every() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

Array.prototype.every(callback) answers one question: do all elements pass this test? It returns a boolean, stops early on the first failure, and does not mutate the array.

Remember
array.every((element, index, array) => test)

all pass  → true
one fails → false (stops early)
empty []  → true

pair with: some()  (any pass?)
read-only · ES5

Syntax

Call array.every. Start with this line.

JavaScript
array.every(callback)
CallWhat it does
array.every(callback)Primary signature.
array.every(...)Call with the arguments your case needs.

Built into JavaScript. Call every(...) on an array instance — no import required.

Library declarations
JavaScript
array.every(callback)

Parameters

ParameterDescription
ArrayRequired. Values to test
CallbackRequired. Returns truthy/falsy per element
thisArgOptional. Optional this for the callback

Return Value

Return ValueDescription
*true or false

JavaScript Examples

Example 1 — Check If All Numbers Are Even

Return true only when every element passes the modulo test.

JavaScript
const numbers = [2, 4, 6, 8, 10];

const allEven = numbers.every((num) => num % 2 === 0);

console.log(allEven);
// true
Try It Yourself

How It Works

  1. Start with even numbers. The array is [2, 4, 6, 8, 10].
  2. Test each value. num % 2 === 0 is true for every item.
  3. All callbacks pass. No early exit — every slot was checked.
  4. Result is true. The whole list satisfies the rule.

Example 2 — Return false When One Element Fails

As soon as a value fails the rule, every() stops.

JavaScript
const numbers = [2, 4, 6, 8, 10];

const allGreaterThanTen = numbers.every((num) => num > 10);

console.log(allGreaterThanTen);
// false
Try It Yourself

How It Works

  1. Ask a harder question. Is every number greater than 10?
  2. First value fails. 2 > 10 is false.
  3. Short-circuit. Remaining numbers are not tested.
  4. Result is false. One failure means “not every”.

Example 3 — Empty Arrays Always Return true

Zero elements means zero failures — a common beginner surprise.

JavaScript
const empty = [];

const result = empty.every((n) => n > 0);

console.log(result);
// true
Try It Yourself

How It Works

  1. No elements to test. The callback never runs.
  2. No failures found. Spec rules say return true.
  3. Vacuous truth. “All items (of which there are none) pass.”
  4. Guard if needed. Check arr.length when empty should mean “invalid”.

Browser & Runtime Support

Array.prototype.every() has been part of JavaScript since ES5 (2009). It is one of the most widely supported array methods.

✓ Baseline · ES5

Array.prototype.every()

Supported in Chrome 1+, Firefox 1.5+, Safari 3+, Edge 12+, IE 9+, and all modern Node.js versions.

99% Universal browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Array.every() Universal

Bottom line: Safe everywhere modern apps run, including IE9+. No polyfill needed for typical targets.

Frequently Asked Questions

every() tests whether every element passes a callback. It returns true only if the callback is truthy for all elements; otherwise it returns false.
No. every() only reads elements through your callback. Avoid changing the array inside the callback.
true. There are zero elements that fail the test (vacuous truth).
Yes. It short-circuits: as soon as one element fails, it returns false without checking the rest.
every() asks “do ALL pass?” and fails on the first false. some() asks “does ANY pass?” and succeeds on the first true.
every() is ES5 (2009). It works in all modern browsers, Node.js, and Internet Explorer 9+.

Next: fill()

Learn how to fill all or part of an array with a static value.

fill() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful