Underscore.js _.isNull() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if the value of object is null (official Underscore docs). undefined and other falsy values 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 _.isNull. Start with this line.

Underscore
_.isNull(object)
CallWhat it does
_.isNull(object)Primary signature.
_.isNull(...)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
_.isNull(object)

Parameters

ParameterDescription
objectRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official Docs

null passes. undefined does not.

Underscore
_.isNull(null);
// → true

_.isNull(undefined);
// → false
Try It Yourself

How It Works

  1. null. Exact primitive match → true.
  2. undefined. Different primitive → false.
  3. Job of the helper. Strict null only.
  4. Takeaway. Cleared (null) ≠ missing (undefined).

Example 2 — Falsy Look-alikes

0, empty strings, false, and objects fail. Only null passes.

Underscore
console.log(_.isNull(0));      // false
console.log(_.isNull(""));     // false
console.log(_.isNull(false));  // false
console.log(_.isNull({}));     // false
console.log(_.isNull(null));   // true
Try It Yourself

How It Works

  1. Falsy values. 0, "", false are not null.
  2. {}. An object is not null.
  3. null. The only pass.
  4. Rule. Falsy ≠ null.

Example 3 — vs == null

Loose equality catches undefined. isNull does not.

Underscore
console.log(_.isNull(null), null == null, null === null);
// → true true true

console.log(_.isNull(undefined), undefined == null, undefined === null);
// → false true false
Try It Yourself

How It Works

  1. null. All three agree → true.
  2. undefined == null. Loose equality → true.
  3. _.isNull(undefined). Strict → false.
  4. Pick the tool. Strict null vs “nullish” check.

Example 4 — Cleared vs Missing

Explicit null vs a missing property vs a real string.

Underscore
var cleared = { nickname: null };
var fresh = {};
var named = { nickname: "Ace" };

console.log(_.isNull(cleared.nickname)); // true
console.log(_.isNull(fresh.nickname));   // false (undefined)
console.log(_.isNull(named.nickname));   // false
Try It Yourself

How It Works

  1. cleared. Field set to null → passes.
  2. fresh. Missing key → undefined → fails.
  3. named. Real string → fails.
  4. Use case. APIs often use null to mean “cleared on purpose.”

Browser & Runtime Support

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

✓ Stable · Underscore 0.4.7+

_.isNull()

Available since [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
_.isNull Underscore 0.4.7+

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

_.isNull(object) returns true only when the value is null. undefined, 0, empty strings, false, and objects all return false.
_.isNull(null) returns true. _.isNull(undefined) returns false. That pair shows the helper only accepts the null primitive, not other falsy or missing values.
value == null is true for both null and undefined because == coerces. _.isNull(null) is true but _.isNull(undefined) is false. Use isNull when you need strict null only.
That is a long-standing JavaScript quirk. typeof null is "object", so typeof alone cannot detect null. _.isNull uses obj === null instead.
No. undefined is a separate primitive. Only null passes _.isNull. To catch both, use value == null or check each case separately.
No. It is a stable Underscore helper (since 0.4.7). Use it for a readable strict null check.

Next: _.isUndefined()

Detect undefined values — the natural pair with isNull.

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