Lodash _.negate() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

Creates a function that returns the opposite of a predicate’s result. The original predicate is called with the same this and arguments. Part of Lodash 4.x Function (since 3.0.0).

Pass the required arguments shown below. Most helpers return a new function you call later.

Syntax

Call _.negate. Start with this line.

Lodash
_.negate(predicate)
CallWhat it does
_.negate(predicate)Primary signature.
_.negate(func)Wrap or transform a function.

Prefer import negate from "lodash/negate" when you want a smaller bundle.

Library declarations
Lodash
_.negate(predicate)

Parameters

ParameterDescription
predicateRequired. Function whose result is flipped

Return Value

Return ValueDescription
*New function → !predicate(...)

Lodash Examples

Example 1 — Official: Filter with _.negate(isEven)

Keep numbers that fail the even test — the odds.

Lodash
function isEven(n) {
  return n % 2 == 0;
}

_.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
// → [1, 3, 5]
Try It Yourself

How It Works

  1. Predicate. isEven returns true for even numbers.
  2. Negate. Wrapper returns the opposite boolean.
  3. Filter. Keeps values where the wrapper is truthy.
  4. Odds. 1, 3, 5 remain.

Example 2 — Call the Negated Function Directly

You do not have to pass it to filter — call it like any function.

Lodash
function isEven(n) {
  return n % 2 == 0;
}

var isOdd = _.negate(isEven);

isOdd(3);
// → true

isOdd(4);
// → false
Try It Yourself

How It Works

  1. Name it. Store _.negate(isEven) as isOdd.
  2. 3. isEven(3) is false → !false → true.
  3. 4. isEven(4) is true → !true → false.
  4. Reuse. Pass isOdd anywhere a predicate is needed.

Example 3 — _.reject vs filter + negate

Same odds — two Lodash styles.

Lodash
function isEven(n) {
  return n % 2 == 0;
}

_.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
// → [1, 3, 5]

_.reject([1, 2, 3, 4, 5, 6], isEven);
// → [1, 3, 5]
Try It Yourself

How It Works

  1. filter + negate. Invert the test, then keep truthy results.
  2. reject. Keep values where the original predicate is falsey.
  3. Same list. Both return the odd numbers.
  4. Pick. Use reject when you already think in “drop matches”; use negate when you need a reusable inverted function.

Example 4 — Invert an Object Field Check

Keep users that are not active.

Lodash
var users = [
  { user: "barney", active: true },
  { user: "fred",   active: false },
  { user: "pebbles", active: true }
];

function isActive(u) {
  return u.active;
}

_.filter(users, _.negate(isActive));
// → [{ user: "fred", active: false }]
Try It Yourself

How It Works

  1. Predicate. isActive reads the active field.
  2. Negate. Wrapper is true when active is false.
  3. Filter. Only fred passes.
  4. Tip. Shorthand _.reject(users, "active") is another option for this case.

Example 5 — Negate Boolean

Keep falsey values by flipping the built-in coerce.

Lodash
_.filter([0, 1, "", "hi", null, true], _.negate(Boolean));
// → [0, "", null]

_.negate(Boolean)(0);
// → true

_.negate(Boolean)("hi");
// → false
Try It Yourself

How It Works

  1. Boolean. Coerces each value to true/false.
  2. Negate. Falsey inputs become true for the wrapper.
  3. Filter. Keeps 0, "", and null.
  4. Direct. Same wrapper works outside filter.

Browser & Runtime Support

_.negate is a Lodash 4.x Function helper (since 3.0.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. There is no single native Function.negate; a one-liner (...a) => !pred(...a) is equivalent, but Lodash keeps the helper consistent with other wrappers.

✓ Stable · Lodash 4.x

_.negate()

Available in [email protected] full builds and the lodash/negate modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.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
_.negate Lodash 4.x+

Bottom line: Safe for production once Lodash is loaded. Prefer import negate from "lodash/negate" for smaller builds. Ideal for reusing an existing predicate in the opposite direction.

Frequently Asked Questions

_.negate(predicate) returns a new function that calls predicate with the same this and arguments, then returns the opposite boolean (!result).
No. It returns a new wrapper. The original function is unchanged.
negate wraps one predicate into its inverse. _.reject(collection, pred) keeps elements where pred is falsey — similar outcome to filter + negate, but reject is a collection helper.
Yes for one-off checks. Use _.negate when you need a reusable inverted function to pass into filter, find, every, or some.
Yes. Lodash invokes the original predicate with the this binding and arguments of the created function.
Use import negate from "lodash/negate" or require("lodash/negate") for tree-shaking. Full build: import _ from "lodash" then _.negate.

Next: _.once()

Create a function that is invoked at most once; later calls return the first result.

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