Underscore.js _.isUndefined() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if value is undefined (official Underscore docs). Missing properties and the undefined primitive pass; null and other falsy values do not. Stable helper — not deprecated.

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

Syntax

Call _.isUndefined. Start with this line.

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

Parameters

ParameterDescription
valueRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official: Missing Variable

The docs check a property that does not exist on window.

Underscore
_.isUndefined(window.missingVariable);
// → true
Try It Yourself

How It Works

  1. Missing property. window.missingVariable was never set.
  2. Read result. JavaScript yields undefined for that access.
  3. Check. Underscore compares with void 0 → true.
  4. Official example. This is the sample from the Underscore documentation.

Example 2 — Undefined vs null

They are different primitives — pick the helper that matches your intent.

Underscore
_.isUndefined(undefined);  // → true
_.isUndefined(null);       // → false

_.isNull(null);            // → true
_.isNull(undefined);       // → false

null == undefined;         // → true  (loose equality)
Try It Yourself

How It Works

  1. isUndefined. Only the undefined primitive passes.
  2. isNull. Only the null primitive passes — see _.isNull.
  3. Loose equality. == null treats both as empty — useful when either means “no value.”
  4. Rule. Prefer the strict helper when APIs distinguish missing vs explicitly empty.

Example 3 — Missing Object Property

Reading a key that was never set yields undefined.

Underscore
var user = { name: "moe" };

_.isUndefined(user.name);     // → false
_.isUndefined(user.age);      // → true
_.isUndefined(user.missing);  // → true
Try It Yourself

How It Works

  1. Present key. user.name is "moe" → not undefined.
  2. Absent key. user.age was never set → reading it gives undefined.
  3. Same for any miss. user.missing also returns undefined.
  4. Use case. Optional fields and config defaults often start this way.

Example 4 — Guard with a Default

Replace undefined with a fallback before you use the value.

Underscore
function label(value) {
  if (_.isUndefined(value)) {
    return "(none)";
  }
  return String(value);
}

label("moe");       // → "moe"
label(undefined);   // → "(none)"
label(null);        // → "null"  (null is not undefined)
Try It Yourself

How It Works

  1. Guard first. Only undefined gets the fallback label.
  2. Present text. "moe" is returned as-is.
  3. Missing value. undefined becomes "(none)".
  4. null stays null. Explicit empty is not treated as missing — convert it separately if needed.

Browser & Runtime Support

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

✓ Stable · Underscore 1.x

_.isUndefined()

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

_.isUndefined(value) returns true only when the value is undefined. null, 0, empty strings, false, and objects all return false.
_.isUndefined(window.missingVariable) returns true. Reading a missing property yields undefined, so the helper reports that the value is missing.
value == null is true for both null and undefined. _.isUndefined(null) is false. Use isUndefined when you need the missing state only.
isNull matches the null primitive. isUndefined matches the undefined primitive. They never both return true for the same value.
The implementation is obj === void 0. void 0 always evaluates to the undefined primitive, even in old environments where the global undefined could be overwritten.
No. It is a stable Underscore helper from the original 0.1.0 release. Load Underscore 1.x and call _.isUndefined(value).

Next: _.isFinite()

Learn how to detect finite numbers — excluding Infinity and NaN.

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