Lodash _.isNull() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Checks if value is exactly null. Part of Lodash Lang (stable — not deprecated). Note: same as value === null — undefined returns false. Use _.isNil when both should match.

Pass the value you want to inspect or convert. Read the return type carefully before you use the result.

Syntax

Call _.isNull. Start with this line.

Lodash
_.isNull(value)
CallWhat it does
_.isNull(value)Primary signature.

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

Library declarations
Lodash
_.isNull(value)

Parameters

ParameterDescription
valueRequired. Value to check

Return Value

Return ValueDescription
*true if value is null, else false

Lodash Examples

Example 1 — Official: null vs undefined

Only the null primitive returns true.

Lodash
console.log(_.isNull(null));   // true
console.log(_.isNull(void 0)); // false
Try It Yourself

How It Works

  1. null. Exact match → true.
  2. void 0. Expression for undefined → false.
  3. Strict. No loose grouping with undefined.
  4. Tip. Need both? Switch to _.isNil.

Example 2 — isNull vs isNil

See how the two helpers disagree on undefined.

Lodash
console.log(_.isNull(null));      // true
console.log(_.isNil(null));       // true

console.log(_.isNull(undefined)); // false
console.log(_.isNil(undefined));  // true
Try It Yourself

How It Works

  1. Both on null. isNull and isNil agree → true.
  2. undefined. isNull rejects; isNil accepts.
  3. Pick. Explicit cleared field → isNull; any missing → isNil.
  4. Loose trap. value == null behaves like isNil, not isNull.

Example 3 — Falsy Values Are Not null

Keep 0, empty string, and false as present values.

Lodash
console.log(_.isNull(0));     // false
console.log(_.isNull(""));    // false
console.log(_.isNull(false)); // false
console.log(_.isNull(NaN));   // false
Try It Yourself

How It Works

  1. Zero / empty / false. Falsy, but not the null primitive.
  2. NaN. Still a number value → false.
  3. Strict identity. Only === null succeeds.
  4. Tip. Do not use !value when you mean “is null.”

Example 4 — Object.create(null) Is Not null

A dictionary object with a null prototype is still an object.

Lodash
var dict = Object.create(null);

console.log(_.isNull(dict));           // false
console.log(Object.getPrototypeOf(dict) === null); // true
Try It Yourself

How It Works

  1. Create. Object.create(null) builds a plain object.
  2. isNull. The value is an object → false.
  3. Prototype. Its prototype happens to be null — different question.
  4. Rule. Check the value, not the prototype chain.

Example 5 — Treat Explicit null Differently

Model APIs that clear a field with null but leave others unset.

Lodash
function statusOf(nickname) {
  if (_.isNull(nickname)) {
    return "cleared";
  }
  if (_.isUndefined(nickname)) {
    return "not set";
  }
  return "set: " + nickname;
}

console.log(statusOf(null));      // cleared
console.log(statusOf(undefined)); // not set
console.log(statusOf("Ada"));     // set: Ada
Try It Yourself

How It Works

  1. null. Explicit clear → "cleared".
  2. undefined. Never provided → "not set".
  3. String. Present value → labeled as set.
  4. Why isNull. Collapsing both with isNil would lose that distinction.

Browser & Runtime Support

_.isNull is a Lodash Lang helper available in 4.x (and earlier 3.x builds). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native engines express the same idea with value === null, but not this helper by name.

✓ Stable · Lodash 4.x

_.isNull()

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

100% With Lodash 4.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 Lodash 4.x

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import isNull from "lodash/isNull" for smaller builds. Equivalent to value === null as a named function.

Frequently Asked Questions

_.isNull(value) returns true only when value is the null primitive. undefined, 0, "", false, and NaN all return false.
No. Only exact null matches. undefined is a separate missing sentinel — use _.isUndefined or _.isNil for that.
Use _.isNull when only explicit null matters. Use _.isNil when either null or undefined should take the same branch.
Yes. Loose equality groups null and undefined together. _.isNull is strict — like value === null — and excludes undefined.
No. That creates an ordinary object whose prototype is null. The value itself is still an object, not the null primitive.
Use import isNull from "lodash/isNull" or require("lodash/isNull") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.isNull.

Next: _.isNumber()

Check whether a value is classified as a number.

_.isNumber() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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