Lodash _.isBoolean() method

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

What you’ll learn

  • How _.isBoolean(value) classifies boolean primitives and wrappers.
  • Why truthy/falsy checks are not boolean type checks.
  • How this compares to typeof value === "boolean".
  • How to validate booleans from JSON or query strings safely.

Prerequisites

Comfort with boolean literals, truthiness, and the difference between types and runtime coercion.

  • You understand typeof versus object wrappers.
  • You can open Try-it labs in the browser.

Overview

_.isBoolean is the lodash helper for strict boolean typing—ideal for validating flags in configuration objects, parsed JSON, or user-controlled inputs without treating numbers or strings as booleans by accident.

Primitives

true and false literals always pass.

Boxed Booleans

new Boolean(...) is detected—unlike a bare typeof check.

Not truthiness

0, "", and null stay non-booleans even when falsy.

Syntax

javascript
_.isBoolean(value)
  • value: any value to test.
  • Returns: true if value is a boolean primitive or Boolean object; otherwise false.
1

Boolean primitives

Both boolean literals classify cleanly—this is the common case for flags and predicates.

javascript
import isBoolean from "lodash/isBoolean";

isBoolean(true);       // true
isBoolean(false);      // true
Try it Yourself
2

Boxed Booleans versus impostors

new Boolean(false) is still typed as a Boolean wrapper. Numbers and strings—even when they look like flags—fail.

javascript
import isBoolean from "lodash/isBoolean";

isBoolean(new Boolean(false)); // true (boxed)

isBoolean(1);                  // false
isBoolean("true");             // false
Try it Yourself
3

Boolean(...) versus boolean typing

The Boolean function coerces values into primitives—those results are booleans. Plain numbers remain non-booleans even when truthy.

javascript
import isBoolean from "lodash/isBoolean";

isBoolean(Boolean(0));      // true — primitive false

isBoolean(42);              // false — still a number

isBoolean(JSON.parse("true")); // true — JSON boolean literal
Try it Yourself

📋 _.isBoolean vs other checks

ApproachBooleans detected
_.isBoolean(x)Primitives + Boolean objects.
typeof x === "boolean"Primitives only.
x === true || x === falseStrictly the two literals.
Truthy / falsy testsMany non-boolean types; not a substitute.

Pitfalls to avoid

Forms

Checkbox DOM values

Unchecked boxes often omit keys or submit strings—normalize before treating inputs as booleans.

Wrappers

new Boolean(false) is truthy

Boxed false still behaves like an object in conditionals; unwrap with Boolean(x) or avoid wrappers entirely.

Schemas

Validation libraries

For complex payloads prefer schema validators; use _.isBoolean for quick lodash-native guards.

❓ FAQ

No. Many values are truthy or falsy without being booleans—empty strings, zero, null. _.isBoolean only tests whether the value is classified as a boolean primitive or Boolean object.
For primitives, yes. For boxed Booleans (new Boolean(...)), typeof returns object while _.isBoolean still returns true.
Rarely—boxed booleans are surprising in conditionals. Prefer plain true/false literals.
Strings are never booleans until you parse or coerce explicitly; validate schema at your API boundary.

Summary

  • Purpose: strict boolean typing including wrappers.
  • Not: a replacement for truthiness or numeric zero checks.
  • Next: explore more on Lodash _.isBuffer().
Did you know?

typeof false === "boolean" only catches primitives. Lodash’s _.isBoolean also returns true for values created with new Boolean(...), which typeof reports as "object".

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