Lodash _.isNumber() method

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

What you’ll learn

  • How _.isNumber(value) combines typeof checks with boxed Number tagging.
  • Why NaN and infinities still register as numbers.
  • How strings and booleans differ from numeric primitives.
  • Which lodash helpers narrow numbers further (_.isFinite, _.isInteger, _.isNaN).

Prerequisites

You know JavaScript distinguishes number primitives from numeric strings.

  • You have seen wrapper objects like Object(42).
  • Try-it labs load lodash from the CDN.

Overview

Use _.isNumber as the first gate for math utilities, schema validators, or analytics payloads—then chain tighter guards when NaN or infinity must be excluded.

Primitives

typeof value === "number" covers literals like 3 and -0.

Boxed numbers

[object Number] tagging detects legacy wrappers.

Extremes included

NaN and ±Infinity still count—narrow with _.isFinite.

Syntax

javascript
_.isNumber(value)
  • value: any value to test.
  • Returns: true if classified as a Number primitive or boxed Number object.
1

Ordinary numeric primitives

Integers, floats, and tiny magnitudes like Number.MIN_VALUE pass—matching lodash docs.

javascript
import isNumber from "lodash/isNumber";

console.log(
  "three: " + isNumber(3) + "\n" +                          // true
  "minVal: " + isNumber(Number.MIN_VALUE)                  // true
);
Try it Yourself
2

Infinity and NaN

Lodash follows ECMAScript: non-finite values are still typeof number—use _.isFinite when you need finite math only.

javascript
import isNumber from "lodash/isNumber";

console.log(
  "infinity: " + isNumber(Infinity) + "\n" + // true
  "nan: " + isNumber(NaN)                     // true
);
Try it Yourself
3

Numeric strings versus boxed numbers

Strings fail until coerced; boxed Number objects satisfy the tag check.

javascript
import isNumber from "lodash/isNumber";

console.log(
  "numericStr: " + isNumber("3") + "\n" +       // false
  "boxed: " + isNumber(Object(42))              // true
);
Try it Yourself

📋 _.isNumber vs related checks

APIBehavior
_.isNumber(x)Number primitive or boxed Number—including NaN and ±Infinity.
_.isFinite(x)Requires finite primitive number (filters NaN and infinities).
_.isInteger(x)Finite integer primitives only—no strings or boxed numbers.
typeof x === "number"Matches primitives but misses Object(7).

Pitfalls to avoid

Forms

Query strings

HTTP parameters arrive as strings—parse before expecting _.isNumber to pass.

BigInt

Arbitrary precision

BigInt literals are not IEEE doubles—lodash intentionally returns false.

Validation

NaN propagation

_.isNumber(NaN) is true; combine with _.isNaN when NaN must be rejected.

❓ FAQ

Yes. Lodash follows ECMAScript typing—use _.isFinite when those extremes must be rejected.
Numeric strings stay typeof "string" until you coerce with Number() or parse functions.
Objects wrapping numbers brand as [object Number], so Object(7) passes.
BigInt is a distinct primitive type—typeof bigint—so lodash returns false.

Summary

  • Purpose: classify Number primitives and boxed numbers consistently.
  • Remember: widen or narrow with _.isFinite, _.isInteger, or _.isNaN as needed.
  • Next: explore more on Lodash _.isObject().
Did you know?

Lodash treats NaN and Infinity as numbers because typeof reports "number"—reach for _.isFinite when you need real finite arithmetic values.

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