Lodash _.every() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.every(collection, predicate) validates a rule across an entire collection.
  • Short-circuit behavior and why side effects inside predicates are risky.
  • How Lodash compares to native Array.prototype.every and to _.some.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.

Prerequisites

Optional warm-up: _.countBy() for grouping patterns before validation-style iteration.

  • You can write predicates that return strict booleans.
  • You can open Try-it labs or run snippets locally.

Overview

_.every encodes universal checks—permissions matrices, batch validators, “all rows qualify” guards—while exiting early the moment one element breaks the rule.

Short-circuits

Failed checks stop traversal—useful when predicates are expensive or collections are large.

Iteratee sugar

Reuse Lodash iteratee styles—functions, paths, or partial object constraints.

Arrays or objects

The same helper walks indexed lists or keyed plain objects consistently.

Syntax

javascript
_.every(collection, predicate)
  • collection: array, array-like, or plain object Lodash can iterate.
  • predicate: invoked as (value, index|key, collection); falsy results fail the check.
  • Returns: boolean—true only when every invocation is truthy (including empty collections).
1

Numeric guard with a function predicate

Confirm every reading stays inside an acceptable band before aggregating metrics.

javascript
import every from "lodash/every";

every([62, 70, 68], (temp) => temp >= 60 && temp <= 72);
// → true
Try it Yourself
2

Partial object match iteratee

Lodash compares each element against the template object—handy for uniform flag checks across rows.

javascript
import every from "lodash/every";

every(
  [
    { id: 1, role: "editor", active: true },
    { id: 2, role: "viewer", active: true }
  ],
  { active: true }
);
// → true
Try it Yourself
3

Empty collections and vacuous truth

No elements means no counterexamples—both Lodash and native every resolve to true. Validate length first when emptiness should fail your domain rule.

javascript
import every from "lodash/every";

every([], () => false);
// → true (predicate never runs)
Try it Yourself

📋 _.every vs some, native every

APIOutcomeBest when
_.every(collection, predicate)All elements passUniversal validation across arrays or objects
_.some(collection, predicate)At least one passesExistential checks or early wins
array.every(predicate)All elements passPure arrays without Lodash iteratee sugar

Pitfalls to avoid

Empty

Vacuous passes

Guard minimum cardinality yourself when “must have at least one row” is part of the business rule.

Effects

Side effects in predicates

Short-circuiting means later elements might never run—keep predicates pure or explicitly document ordering assumptions.

Coercion

Truthy versus strict true

Lodash treats predicate results with ordinary truthiness rules—return explicit booleans when ambiguity hurts readability.

❓ FAQ

No. Lodash only reads values while evaluating your predicate; the collection is unchanged.
true—the predicate is never falsified because there are no elements (vacuous truth), matching native Array.every.
Yes. Once an element fails the predicate, Lodash returns false without visiting remaining elements.
every requires all matches; some stops at the first truthy predicate result. Negating predicates swaps typical use cases.
Yes—Lodash accepts iteratee forms such as property names, path arrays, or partial object matches like other collection methods.

Summary

  • Purpose: _.every(collection, predicate) returns whether every element satisfies the predicate.
  • Contrast: flip to _.some for existential checks; remember empty collections yield true.
  • Next: Lodash _.filter(), Lodash _.countBy() (previous), or collection hub.
Did you know?

For an empty collection, Lodash _.every returns true—the same vacuous-truth behavior as Array.prototype.every. Pair that rule with _.some when you need “at least one” instead.

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.

6 people found this page helpful