Lodash _.stubFalse() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Util

Definition

This method returns false. Part of Lodash Util since 4.13.0 (stable — not deprecated).

Note: Arguments are ignored. Equivalent idea to _.constant(false), with a clearer name for boolean stubs.

Syntax

Call _.stubFalse. Start with this line.

Lodash
_.stubFalse()
CallWhat it does
_.stubFalse()Primary signature.
_.stubFalse(...)Call the util helper.

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

Library declarations
Lodash
_.stubFalse()

Parameters

This method has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Always false

Lodash Examples

Example 1 — Official: _.times + stubFalse

Build an array of false values.

Lodash
_.times(2, _.stubFalse);
// → [false, false]
Try It Yourself

How It Works

  1. Pass by reference. _.stubFalse — no trailing ().
  2. Invoke twice. _.times calls it for indexes 0 and 1.
  3. Each call. Returns false.
  4. Collect. Result array is [false, false].

Example 2 — Direct Call

Invoke the stub yourself when you need a boolean now.

Lodash
_.stubFalse();
// → false

_.stubFalse();
// → false
Try It Yourself

How It Works

  1. Call. Empty parentheses run the stub.
  2. Return. Always the boolean false.
  3. Again. Same result on the next call.
  4. Use. Quick default for flags and mocks.

Example 3 — Arguments Are Ignored

Host APIs may pass indexes or values — the stub still returns false.

Lodash
_.stubFalse(true);
// → false

_.stubFalse(1, 2, 3);
// → false
Try It Yourself

How It Works

  1. Ignore input. Even true does not change the result.
  2. Ignore extras. Multiple args still yield false.
  3. Safe callback. Fits APIs that forward indexes or items.
  4. Contrast. Unlike _.identity, input never passes through.

Example 4 — Filter Everything Out

As a predicate, every item fails — useful as a reject-all mock.

Lodash
_.filter([1, 2, 3], _.stubFalse);
// → []
Try It Yourself

How It Works

  1. Predicate. Filter keeps items when the callback is truthy.
  2. Always false. Every call fails the check.
  3. Result. Empty array.
  4. Use. Disable a filter path without rewriting the call site.

Example 5 — stubFalse vs stubTrue

Opposite boolean stubs side by side.

Lodash
_.stubFalse();
// → false

_.stubTrue();
// → true

_.times(2, _.stubTrue);
// → [true, true]
Try It Yourself

How It Works

  1. stubFalse. Fixed false.
  2. stubTrue. Fixed true.
  3. times. Same pattern fills an array of true.
  4. Pick. Match the boolean your API or mock needs.

Browser & Runtime Support

_.stubFalse is a Lodash Util helper since 4.13.0. It runs anywhere Lodash 4.13+ runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 4.13.0+

_.stubFalse()

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

100% With Lodash 4.13+
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
_.stubFalse Lodash 4.13.0+

Bottom line: Safe for production once Lodash 4.13+ is loaded. Prefer import stubFalse from "lodash/stubFalse" for smaller bundles. Use it as a named always-false callback.

Frequently Asked Questions

_.stubFalse() returns false every time it is called. Official: _.times(2, _.stubFalse) → [false, false].
No. Any arguments are ignored. _.stubFalse(true) is still false.
Same return value. stubFalse is a named util with no arguments to configure. constant(false) builds an equivalent function.
stubTrue always returns true; stubFalse always returns false. Both ignore arguments.
As a filter/validation mock that rejects everything, a default false predicate, or with _.times to fill an array of false values.
Use import stubFalse from "lodash/stubFalse" or require("lodash/stubFalse"). Full build: import _ from "lodash" then _.stubFalse.

Next: _.stubObject()

Return a new empty object on every call.

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