Lodash _.stubFalse() Method

Beginner
⏱️ 6 min read
📚 Updated: Jul 2026
🎯 6 Examples + 3 Try It
Util utilities

What You’ll Learn

By the end of this tutorial, you’ll use Lodash’s _.stubFalse() as a named “always false” function—for predicates, mocks, and disabled feature gates.

01

Core Syntax

_.stubFalse()

02

Always false

Any args ignored.

03

Fn reference

_.stubFalse

04

Predicates

Filter / some.

05

vs constant

constant(false)

06

vs stubTrue

Opposite stub.

What Is _.stubFalse()?

_.stubFalse is a zero-argument function that always returns false. It belongs to Lodash’s stub helper family alongside _.stubArray() and _.stubTrue(). Under the hood it is equivalent to _.constant(false).

💡
Beginner tip — function vs boolean

_.stubFalse() gives you the value false. _.stubFalse (no parentheses) is the function itself—pass it when Lodash or your code expects a predicate callback.

Use it when you need a readable, reusable “never passes” check—clearer than sprinkling () => false through cond tables and filter pipelines.

📝 Syntax

Invoke with no arguments (they are ignored anyway):

javascript
_.stubFalse()

Syntax Rules

  • _.stubFalse — function reference for predicates and callbacks.
  • _.stubFalse() — call once to get boolean false.
  • Ignores arguments_.stubFalse(1, "x", {}) still returns false.
  • Not a catch-all — in _.cond, use _.stubTrue for default branches, not stubFalse.
  • Primitive false — returns the boolean false, not 0 or "".
javascript
import stubFalse from "lodash/stubFalse";



stubFalse();

// false

⚡ Quick Reference

TaskCode patternNotes
Get false now_.stubFalse()Boolean value
Fail predicate_.filter(arr, _.stubFalse)Empty result
Disabled checkconst ok = _.stubFalseFn reference
Mock validatorvalidate: _.stubFalseAlways invalid
Equivalent_.constant(false)Same behavior
Default in cond_.stubTrueNot stubFalse
Returns
false

Boolean

Type
Function

Zero-arg

Args
Ignored

Always false

Category
Util

Stub

🧰 Parameters

_.stubFalse accepts no meaningful parameters—callers may pass args, but stubFalse ignores them:

arguments Ignored

Any values passed when stubFalse is used as a callback are discarded.

_.stubFalse(1, 2, 3)
return false

Always the boolean primitive false.

false
reference Pattern

Pass _.stubFalse without () to APIs expecting a function.

_.some(arr, _.stubFalse)
call once Pattern

Use _.stubFalse() when you need the value—not a callable function reference.

return _.stubFalse()

Need always-true instead? See _.stubTrue()—especially as the default pair in _.cond().

Examples Gallery

Practical _.stubFalse() patterns with copy-ready code, sample output, and interactive Try It Yourself labs.

📚 Getting Started

Call stubFalse and confirm the result.

Example 1 — Basic call returns false

The simplest use—evaluate to boolean false.

javascript
console.log(_.stubFalse());

console.log(typeof _.stubFalse());

console.log(_.stubFalse() === false);

// false

// "boolean"

// true
Try It Yourself

How It Works

Same result as writing false directly—stubFalse names the intent in Lodash-heavy code.

Example 2 — Arguments are ignored

Whether called with zero or many args, the answer is always false.

javascript
console.log(_.stubFalse());

console.log(_.stubFalse("anything"));

console.log(_.stubFalse(99, { ok: true }));

// false, false, false
Try It Yourself

How It Works

Like _.constant(false), stubFalse never inspects callback arguments from _.filter or _.some.

📈 Practical Patterns

Predicates, disabled features, and test mocks.

Example 3 — Filter nothing with _.stubFalse

Pass the function reference—every element fails the predicate.

javascript
const nums = [1, 2, 3, 4, 5];



console.log(_.filter(nums, _.stubFalse));

console.log(_.some(nums, _.stubFalse));

// []

// false
Try It Yourself

How It Works

Useful for temporarily disabling a filter branch while keeping pipeline structure intact.

Example 4 — Disabled feature gate (function reference)

Store the stub as a callable check— not _.stubFalse() which is just the boolean.

javascript
const isFeatureEnabled = _.stubFalse;



if (isFeatureEnabled()) {

  console.log("Feature on");

} else {

  console.log("Feature off");

}

// Feature off

How It Works

Old tutorials wrote const f = _.stubFalse() then f()—that throws because false is not callable. Assign _.stubFalse instead.

Example 5 — Mock validator that always fails

Pass stubFalse where a validation function is expected.

javascript
function submitForm(data, validate = _.stubFalse) {

  return validate(data);

}



console.log(submitForm({ name: "Ada" }));

// false — validation always fails

How It Works

Default parameter uses the function reference so callers can swap in a real validator later.

🚀 Beyond the Basics

stubFalse vs constant, arrow, and stubTrue.

Example 6 — stubFalse vs alternatives

Pick the right always-false tool—and know when stubTrue fits cond instead.

javascript
console.log(_.stubFalse());

console.log(_.constant(false)());

console.log((() => false)());



console.log(_.stubFalse === _.constant(false)); // often true in Lodash



// cond default — use stubTrue, not stubFalse:

// _.cond([[_.stubTrue, () => "default"]])

// false, false, false

When to use which

stubFalse for never-pass predicates; stubTrue for cond catch-alls; plain false when a function is not required.

🧠 How _.stubFalse() Works

1

Invoke stub

Call directly or pass _.stubFalse as a callback.

Call
2

Skip logic

No conditionals—implementation always yields false.

Evaluate
3

Ignore args

Elements, indexes, or user data passed by iteratees are unused.

Ignore
=

false

Boolean primitive—fails every truthiness check and filter predicate.

📝 Notes

  • _.stubFalse() returns false—do not call the result again as a function.
  • For callable disabled gates, assign const fn = _.stubFalse (reference).
  • Do not use stubFalse as the default branch in _.cond—use _.stubTrue instead.
  • Setting object fields with isAdmin: _.stubFalse() stores boolean false—same as false, not a function.
  • Equivalent to _.constant(false) for behavior; stubFalse is more readable in stub-family code.
  • Next in the series: _.stubObject()—empty object stub.

Conclusion

_.stubFalse() is a small named helper for “always false”—whether you need a boolean now or a predicate callback that never passes. Pair it with the rest of the stub family for consistent functional style.

Remember the parentheses rule: reference for callbacks, call when you want the value. For catch-all cond branches, reach for stubTrue instead.

💡 Best Practices

✅ Do

  • Pass _.stubFalse to filter/some when nothing should match
  • Use as a default validator that always fails in tests
  • Prefer stubFalse over () => false in Lodash cond/filter tables
  • Use _.stubTrue for cond default branches
  • Return false or _.stubFalse() directly when no callback is needed

❌ Don’t

  • Assign const f = _.stubFalse() then call f()
  • Use stubFalse as a cond catch-all—it never matches as intended default
  • Expect stubFalse to return falsy non-booleans like 0 or ""
  • Put stubFalse in object literals expecting a function property without noticing ()
  • Confuse with _.noop—noop returns undefined, not false

Key Takeaways

Knowledge Unlocked

Five things to remember about _.stubFalse()

Use these points for always-false predicates and mocks.

5
Core concepts
🔄 02

Fn vs ()

Ref vs value.

Pitfall
03

Filter none

Predicate.

Usage
📝 04

constant

Same idea.

Related
🛠 05

stubTrue

Opposite.

Compare

❓ Frequently Asked Questions

_.stubFalse is a zero-argument function that always returns false. Call _.stubFalse() when you need the boolean false immediately, or pass _.stubFalse (no parentheses) when an API expects a function that always fails its check.
false is a value. _.stubFalse is a function—useful when something expects a callback or predicate. _.stubFalse() evaluates to false, same as calling the function once.
_.stubFalse is sugar for _.constant(false). Both always return false and ignore arguments. stubFalse reads clearer in Lodash stub/cond style code.
Pass _.stubFalse to _.filter, _.some, or option slots that want a function. Use _.stubFalse() when you need the boolean value right now—like return false or assign a flag. Do not call it then try to invoke the result as a function.
stubTrue always returns true—common as the default branch in _.cond. stubFalse always returns false—useful for disabled predicates, empty filters, or mocks that always fail validation.
Use it for always-fail predicates, placeholder disabled feature checks, test mocks, and anywhere () => false reads well but you prefer a named Lodash helper.
Did you know?

Lodash pairs _.stubTrue with _.cond for default branches because it always passes—_.stubFalse is the opposite tool for predicates that should never pass, like filtering zero items or stubbing failed validation.

Practice _.stubFalse() in the Live Editor

Try basic false returns, ignored arguments, and filter-nothing predicates.

Open Try It editor →

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