Underscore.js _.isBoolean() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if object is either true or false (official Underscore docs). Falsy look-alikes such as null, 0, and "false" return false.

Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.

Syntax

Call _.isBoolean. Start with this line.

Underscore
_.isBoolean(object)
CallWhat it does
_.isBoolean(object)Primary signature.
_.isBoolean(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.isBoolean(object)

Parameters

ParameterDescription
objectRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official Docs

The docs show null failing. A real boolean passes.

Underscore
_.isBoolean(null);
// → false

_.isBoolean(true);
// → true
Try It Yourself

How It Works

  1. Test null. Famous falsy value, but not a boolean → false.
  2. Test true. Boolean primitive → true.
  3. Different questions. Truthiness ≠ boolean type.
  4. Takeaway. Use _.isBoolean when the type must be Boolean.

Example 2 — Both true and false Pass

The Boolean type has two values — both succeed.

Underscore
console.log(_.isBoolean(true));       // true
console.log(_.isBoolean(false));      // true
console.log(_.isBoolean(Boolean(1))); // true  (primitive true)
Try It Yourself

How It Works

  1. true. Boolean primitive → passes.
  2. false. Also a boolean → passes (not “falsy fail”).
  3. Boolean(1). Function call returns primitive true → passes.
  4. Rule. The helper answers “is it a boolean?”, not “is it truthy?”.

Example 3 — vs Truthy / Falsy

Values that work in an if statement are not automatically booleans.

Underscore
console.log(_.isBoolean(1), _.isBoolean(0));           // false false
console.log(_.isBoolean("false"), _.isBoolean(""));    // false false
console.log(_.isBoolean(null), _.isBoolean(undefined)); // false false
Try It Yourself

How It Works

  1. Numbers. 1 is truthy, 0 is falsy — both fail the type check.
  2. Strings. "false" looks like a boolean word but is a string.
  3. null / undefined. Falsy, but different types → fail.
  4. Rule. Convert with !!value only when truthiness is enough.

Example 4 — vs typeof (Boxed Boolean)

typeof misses boxed Boolean objects. Underscore does not.

Underscore
console.log(_.isBoolean(true), typeof true);
// → true "boolean"

console.log(_.isBoolean(new Boolean(true)), typeof new Boolean(true));
// → true "object"
Try It Yourself

How It Works

  1. Primitive. typeof true is "boolean" — agrees with Underscore.
  2. Boxed. new Boolean(true) is an object to typeof.
  3. Tag check. Underscore sees [object Boolean] → still true.
  4. Prefer primitives. In new code, use true/false, not new Boolean().

Browser & Runtime Support

_.isBoolean ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.

✓ Stable · Underscore 1.x

_.isBoolean()

Available in [email protected] (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded.

100% With Underscore 1.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
_.isBoolean Underscore 1.x+

Bottom line: Safe for production once Underscore is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.isBoolean(object) returns true only when the value is true or false — the two boolean primitives — or a boxed new Boolean() object. null, 0, 1, "true", "false", and undefined return false.
_.isBoolean(null) returns false. The docs pick a famous falsy value on purpose: null is not a boolean, even though if (null) is skipped.
Yes. _.isBoolean(true) and _.isBoolean(false) are both true. Underscore’s tests say “but true is, and so is false.”
Truthy values such as 1, "yes", and {} pass if (value). They fail isBoolean. Falsy values such as 0, "", null, and undefined also fail isBoolean. Only the two boolean values pass.
typeof true === "boolean" agrees for primitives. typeof new Boolean(true) is "object", so typeof misses boxed booleans. Underscore also checks the [object Boolean] tag, so boxed values pass.
No. It is a stable Underscore 1.x helper used to decide whether a flag is a real boolean before you branch on it.

Next: _.isDate()

Test whether a value is a Date object — another core Underscore type check.

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