Lodash _.isUndefined() method

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

What you’ll learn

  • How _.isUndefined(value) performs a strict === undefined check.
  • Why null, 0, and "" are not considered undefined.
  • How to choose between _.isUndefined and _.isNil.
  • Where this guard fits in default-value and optional-prop handling.

Prerequisites

You know the difference between undefined (no value assigned) and null (intentional empty).

  • You have read or written typeof x === "undefined" guards before.
  • Try-it labs load lodash from the CDN.

Overview

Use _.isUndefined before applying default values, branching on optional parameters, or skipping serialization for unset object properties—without lumping in explicit null.

Strict identity

Returns true only when value is the undefined primitive.

Not null

null is intentional; pair with _.isNil when both should match.

Defaults helper

Ideal companion to _.defaults / ?? coalescing.

Syntax

javascript
_.isUndefined(value)
  • value: any value to test.
  • Returns: true when value === undefined; otherwise false.
1

Bare undefined and void 0

The lodash docs baseline: void 0 evaluates to undefined and passes the guard.

javascript
import isUndefined from "lodash/isUndefined";

let unset;

console.log(
  "void0: " + isUndefined(void 0) + "\n" +    // true (lodash docs)
  "unset: " + isUndefined(unset) + "\n" +      // true
  "literal: " + isUndefined(undefined)         // true
);
Try it Yourself
2

null is not undefined

Lodash docs explicitly contrast: _.isUndefined(null) returns false.

javascript
import isUndefined from "lodash/isUndefined";

console.log(
  "nullVal: " + isUndefined(null) + "\n" +   // false (lodash docs)
  "defined: " + isUndefined("Hello")          // false
);
Try it Yourself
3

Falsy values and missing properties

Numeric zero, empty strings, and false are valid values—only the address property below is genuinely undefined.

javascript
import isUndefined from "lodash/isUndefined";

const user = { name: "John", age: 30 };

console.log(
  "zero: " + isUndefined(0) + "\n" +              // false
  "empty: " + isUndefined("") + "\n" +             // false
  "addrMissing: " + isUndefined(user.address)      // true
);
Try it Yourself

📋 _.isUndefined vs related checks

API / patternBehavior
_.isUndefined(x)true only when x === undefined.
x === undefinedIdentical semantics—lodash wraps the idiom.
typeof x === "undefined"Also matches undeclared identifiers (no ReferenceError).
_.isNil(x)Matches both null and undefined.

Pitfalls to avoid

Defaults

|| trap

value || fallback also overrides 0, "", and false. Prefer _.isUndefined or nullish coalescing ?? for accurate defaults.

Sparse

Sparse arrays

Holes in arrays read as undefined but behave subtly differently from explicit arr[i] = undefined.

Undeclared

Reference errors

Reading a truly undeclared identifier throws before lodash runs—use typeof if you must probe global existence.

❓ FAQ

Yes—lodash literally returns value === undefined. The helper exists for readability and uniform style alongside other type guards.
No. It is strict—use _.isNil if you want a single check that catches both null and undefined.
Reading a declared but unassigned variable yields undefined, so it returns true. Reading an undeclared identifier throws ReferenceError before lodash even runs.
Yes. void 0 evaluates to the undefined primitive, so _.isUndefined(void 0) is true.

Summary

  • Purpose: recognize values strictly equal to undefined.
  • Remember: null, 0, "", and false are all not undefined.
  • Next: explore more on Lodash _.isWeakMap().
Did you know?

Lodash implements _.isUndefined as a one-liner: value === undefined. Historically the helper guarded against legacy environments where undefined could be reassigned—modern strict-mode JS prevents that.

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