Lodash _.isNumber() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Lang

Definition

Checks if value is classified as a Number primitive or object. Part of Lodash Lang (stable — not deprecated). Note: Infinity, -Infinity, and NaN count as numbers — use _.isFinite to exclude them.

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

Syntax

Call _.isNumber. Start with this line.

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

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

Library declarations
Lodash
_.isNumber(value)

Parameters

ParameterDescription
valueRequired. Value to check

Return Value

Return ValueDescription
*true if classified as a number, else false

Lodash Examples

Example 1 — Official: Numbers, Extremes, Strings

Accept number types; reject numeric-looking strings.

Lodash
console.log(_.isNumber(3));                // true
console.log(_.isNumber(Number.MIN_VALUE)); // true
console.log(_.isNumber(Infinity));         // true
console.log(_.isNumber("3"));              // false
Try It Yourself

How It Works

  1. Literal. 3 is a number primitive → true.
  2. MIN_VALUE. Smallest positive number → still a number.
  3. Infinity. Classified as a number in JavaScript → true.
  4. String. "3" stays a string → false.

Example 2 — NaN Counts as a Number

Type check ≠ “usable for arithmetic.”

Lodash
console.log(_.isNumber(NaN));  // true
console.log(_.isNaN(NaN));     // true
console.log(_.isFinite(NaN));  // false
Try It Yourself

How It Works

  1. Type. typeof NaN === "number" → isNumber is true.
  2. Identity. _.isNaN confirms it is Not-a-Number.
  3. Finite. isFinite rejects NaN for real math.
  4. Pick. Type gate → isNumber; usable value → isFinite.

Example 3 — Numeric Strings Stay Strings

No automatic coercion from text to number.

Lodash
console.log(_.isNumber("3"));          // false
console.log(_.isNumber(Number("3")));  // true
console.log(_.isString("3"));          // true
Try It Yourself

How It Works

  1. Raw string. Looks numeric, typed as string → false.
  2. Coerce. Number("3") becomes a real number → true.
  3. isString. Confirms the original type.
  4. Tip. Parse first when input comes from forms or JSON text.

Example 4 — Boxed Number Objects

Object wrappers still count as numbers for Lodash.

Lodash
console.log(_.isNumber(Object(7))); // true
console.log(typeof Object(7));      // "object"
Try It Yourself

How It Works

  1. Wrapper. Object(7) builds a boxed Number object.
  2. typeof. Reports "object", not "number".
  3. Lodash. Checks the internal brand → still true.
  4. Use. Helps when older APIs return boxed primitives.

Example 5 — isNumber vs isFinite

Type classification versus usable finite math values.

Lodash
console.log(_.isNumber(Infinity)); // true
console.log(_.isFinite(Infinity)); // false

console.log(_.isNumber(42));       // true
console.log(_.isFinite(42));       // true
Try It Yourself

How It Works

  1. Infinity. Still a number type → isNumber is true.
  2. Finite gate. isFinite rejects non-finite values.
  3. Normal value. Both helpers accept 42.
  4. Docs tip. Official note: exclude Infinity / NaN with _.isFinite.

Browser & Runtime Support

_.isNumber is a Lodash Lang helper available in 4.x (and earlier builds). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native engines expose related checks via typeof and Number.isFinite, but not this helper by name.

✓ Stable · Lodash 4.x

_.isNumber()

Available in [email protected] full builds and the lodash/isNumber 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
_.isNumber Lodash 4.x

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import isNumber from "lodash/isNumber" for smaller builds. Pair with _.isFinite when Infinity/NaN must fail.

Frequently Asked Questions

_.isNumber(value) returns true when value is classified as a Number primitive or a boxed Number object. That includes NaN and ±Infinity.
Yes. Lodash follows ECMAScript typing — typeof NaN and typeof Infinity are both "number". Use _.isFinite when those extremes must be rejected.
Numeric-looking strings stay typeof "string" until you coerce them with Number() or parse functions.
Yes. Object(7) / new Number(7) brand as Number objects, so _.isNumber accepts them.
BigInt is a distinct primitive (typeof "bigint"), so _.isNumber returns false.
Use import isNumber from "lodash/isNumber" or require("lodash/isNumber") so bundlers can tree-shake unused Lodash code. Full build: import _ from "lodash" then _.isNumber.

Next: _.isObject()

Check whether a value is classified as an object.

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