Lodash _.negate() method

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

What you’ll learn

  • How _.negate flips predicate truthiness.
  • How to reuse one predicate for both positive and inverted checks.
  • How negate compares to manual boolean negation and _.reject.
  • How to avoid confusion when predicates return non-boolean values.

Prerequisites

Helpful reads: _.memoize(), _.filter(), and the Function hub.

  • Predicates: functions that return truthy/falsey outcomes.
  • Collection methods: filtering and finding by predicate callbacks.

Overview

_.negate(predicate) returns a new predicate that yields true when the original returns falsey, and false when the original returns truthy.

Syntax

javascript
_.negate(predicate)
  • predicate: function whose result should be inverted.
  • returns: wrapper predicate with opposite boolean outcome.
1

Invert an is-even predicate

Create isOdd from existing isEven without rewriting logic.

javascript
import negate from "lodash/negate";

const isEven = (n) => n % 2 === 0;
const isOdd = negate(isEven);

isOdd(3); // true
isOdd(4); // false
2

Filter items not matching a rule

Use one predicate for include and exclude flows by inverting it on demand.

javascript
import negate from "lodash/negate";
import filter from "lodash/filter";

const isActive = (item) => item.active === true;
const inactiveUsers = filter(
  [{ id: 1, active: true }, { id: 2, active: false }],
  negate(isActive)
);
// [{ id: 2, active: false }]
3

Find first non-empty string

Invert an isEmptyString check to quickly locate valid values.

javascript
import negate from "lodash/negate";

const isEmptyString = (value) => value === "";
const isNonEmptyString = negate(isEmptyString);

["", "", "ready"].find(isNonEmptyString);
// "ready"

📋 _.negate vs _.reject vs manual !

ApproachBest forTrade-off
_.negateReusable inverted predicate functionsExtra wrapper function
_.rejectOne-off inverse filtering on collectionsTied to collection operation
Manual !Inline quick checksLess reusable and can get noisy in pipelines

Pitfalls to avoid

Truthiness

Non-boolean predicate returns

Negate applies logical NOT to truthy/falsey values, so ensure predicate outputs are intentional.

Naming

Confusing double negatives

Prefer clear names like isNotArchived to avoid hard-to-read conditions.

Scope

Needless wrappers

For a single inline check, plain ! may be simpler than storing a new negated function.

❓ FAQ

It creates a predicate wrapper that returns the opposite boolean result of the original predicate.
It is handy when you already have a predicate and need the inverse for filter, reject, or find-like operations.
No. It forwards the same arguments and context to the original predicate, then negates the result.
Yes for one-off checks, but _.negate is cleaner when you need a reusable inverted predicate function.
Not exactly. negate wraps one predicate; reject is a collection helper that internally keeps values where predicate is false.

Summary

Did you know?

Lodash _.negate(predicate) returns a wrapper that preserves incoming arguments and this, then flips the predicate result with logical NOT.

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