Underscore.js _.every() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Collection

Definition

Returns true if all of the values in the list pass the predicate truth test. Stops early when a false element is found (official Underscore docs). Stable Collection helper — not deprecated.

Pass the required arguments shown below. Underscore collection helpers usually return a new value — check whether the source is mutated.

Syntax

Call _.every. Start with this line.

Underscore
_.every(list, [predicate], [context])
CallWhat it does
_.every(list, [predicate], [context])Primary signature.
_.every(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.every(list, [predicate], [context])

Parameters

ParameterDescription
listRequired. Array, array-like, or plain object
predicateOptional. Test; defaults to identity (truthy check)
contextOptional. Bound as this in the predicate

Return Value

Return ValueDescription
*true if all pass, else false

Underscore.js Examples

Example 1 — Official Docs Check

Ask whether every number is even — 5 fails the test.

Underscore
_.every([2, 4, 5], function (num) {
  return num % 2 == 0;
});
// → false
Try It Yourself

How It Works

  1. 2 and 4. Both even → predicate returns true.
  2. 5. Odd → predicate returns false.
  3. Stop. Underscore short-circuits and returns false.
  4. Docs sample. This is the official Underscore example.

Example 2 — All Values Pass

When every item succeeds, you get true.

Underscore
_.every([2, 4, 6], function (num) {
  return num % 2 == 0;
});
// → true

_.every([1, 2, 3], function (n) {
  return n > 0;
});
// → true
Try It Yourself

How It Works

  1. Scan. Each value is tested in order.
  2. No failures. Nothing returns a falsy predicate result.
  3. Done. Underscore returns true.
  4. Use case. Form validation, “all ready?”, permission checks.

Example 3 — Matcher & Property Shorthand

Pass an object or property name instead of writing a function.

Underscore
var users = [
  { name: "Ada", active: true },
  { name: "Lin", active: true }
];

_.every(users, { active: true });
// → true

_.every(users, "active");
// → true

users[1].active = false;
_.every(users, { active: true });
// → false
Try It Yourself

How It Works

  1. Matcher. { active: true } means “matches these properties.”
  2. Property. "active" checks that the property is truthy.
  3. Flip. After setting active: false, _.every fails.
  4. Shorthand. Underscore runs the predicate through iteratee.

Example 4 — Empty List, Identity & Alias

Empty lists pass; omit the predicate to require truthy values; _.all matches _.every.

Underscore
_.every([]);                 // true  (vacuous truth)
_.every([1, "ok", true]);    // true  (identity = truthy)
_.every([1, 0, true]);       // false (0 is falsy)

_.all([2, 4, 6], function (n) {
  return n % 2 == 0;
});
// → true  (alias)

_.all === _.every;
// → true
Try It Yourself

How It Works

  1. Empty. No failing item exists → true.
  2. Identity. Omitted predicate checks that each value is truthy.
  3. 0 fails. Falsy values make identity _.every return false.
  4. Alias. _.all is the same function as _.every.

Browser & Runtime Support

_.every (alias _.all) ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.

✓ Stable · Underscore 1.x

_.every()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.x
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
_.every Underscore 1.x+

Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.every(list, [predicate], [context]) returns true only if all values pass the predicate. Official example: _.every([2, 4, 5], n => n % 2 == 0) → false.
Yes. all is an alias of every. They are the same function.
Yes. It short-circuits — as soon as one value fails, it stops and returns false.
_.every([]) returns true (vacuous truth): there is no failing element.
_.every needs all values to pass (AND). _.some needs at least one (OR).
Yes. Pass an object matcher, a property name string, or omit the predicate to test identity (all values truthy).

Next: _.some()

Return true when at least one value passes the predicate — the OR cousin of _.every().

_.some() 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.

10 people found this page helpful