Lodash _.isNaN() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Checks if value is NaN. Based on Number.isNaN — not the same as global isNaN, which coerces non-numbers. Part of Lodash Lang since 0.1.0 (stable — not deprecated).

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

Syntax

Call _.isNaN. Start with this line.

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

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

Library declarations
Lodash
_.isNaN(value)

Parameters

ParameterDescription
valueRequired. The value to check

Return Value

Return ValueDescription
*true if NaN, else false

Lodash Examples

Example 1 — Official: NaN

The NaN primitive is detected correctly.

Lodash
_.isNaN(NaN);
// → true
Try It Yourself

How It Works

  1. Input. Official sample: the value NaN.
  2. Type. It is a number whose value is NaN.
  3. Trap. NaN === NaN is false — use a helper.
  4. Result. true.

Example 2 — Official: Boxed Number(NaN)

Lodash also accepts boxed Number objects wrapping NaN.

Lodash
_.isNaN(new Number(NaN));
// → true

Number.isNaN(new Number(NaN));
// → false  // objects are not number primitives
Try It Yourself

How It Works

  1. Boxed. new Number(NaN) is a Number object.
  2. Lodash. Classifies it as a number that is NaN → true.
  3. Native. Number.isNaN requires a number primitive → false.
  4. Prefer primitives in app code; still know Lodash covers boxed cases.

Example 3 — Official: undefined vs Global

Global isNaN coerces; Lodash does not.

Lodash
isNaN(undefined);
// → true

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

How It Works

  1. Global. Coerces undefined to NaN → true.
  2. Lodash. undefined is not a number → false.
  3. Docs note. This is the main reason to prefer _.isNaN.
  4. Related. Use _.isNil for nullish checks.

Example 4 — Strings Are Not NaN

Common coercion traps with global isNaN.

Lodash
_.isNaN('NaN');   // → false
_.isNaN('abc');   // → false
isNaN('abc');     // → true  (global coerces)

_.isNaN(Number('abc')); // → true  (after parsing)
Try It Yourself

How It Works

  1. Strings. Not numbers → Lodash returns false.
  2. Global trap. isNaN('abc') coerces to NaN → true.
  3. Parse first. Number('abc') yields real NaN.
  4. Pattern. Coerce with _.toNumber, then check.

Example 5 — Math Results and Valid Numbers

Invalid math produces NaN; normal numbers do not.

Lodash
_.isNaN(0 / 0);        // → true
_.isNaN(Number.NaN);   // → true
_.isNaN(1);            // → false
_.isNaN(Infinity);     // → false
Try It Yourself

How It Works

  1. Invalid math. 0 / 0 is NaN → true.
  2. Constant. Number.NaN is the same NaN value.
  3. Finite numbers. Regular integers fail the NaN check.
  4. Infinity. Not NaN — use _.isFinite for finiteness.

Browser & Runtime Support

_.isNaN is a Lodash Lang helper (available since 0.1.0, stable in 4.x). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Behavior is aligned with Number.isNaN (plus boxed Number support).

✓ Stable · Lodash 0.1.0+

_.isNaN()

Available in [email protected] full builds and the lodash/isNaN 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
_.isNaN Lodash 0.1.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import isNaN from "lodash/isNaN" for smaller builds. Native alternative for primitives: Number.isNaN(value).

Frequently Asked Questions

_.isNaN(value) returns true if value is NaN — including the NaN primitive and boxed new Number(NaN). Non-numbers like undefined and strings return false.
No. Global isNaN coerces values first, so isNaN(undefined) and isNaN("abc") are true. Lodash does not coerce — it is based on Number.isNaN-style intent.
Almost. Lodash also returns true for boxed Number(NaN), while Number.isNaN(new Number(NaN)) is false.
NaN is never equal to itself with ===. Use _.isNaN, Number.isNaN, or the idiom value !== value.
No. The string "NaN" is not a number. Global isNaN("NaN") is true only because of coercion.
Use import isNaN from "lodash/isNaN" or require("lodash/isNaN"). Full build: import _ from "lodash" then _.isNaN.

Next: _.isNative()

Check whether a value is a native function from the JavaScript engine.

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