What Types Does Lodash _.isNumber Accept?

The Lodash _.isNumber method is a utility function used to verify whether a given value qualifies as a number. This guide outlines the specific types of numbers and representations accepted by _.isNumber, explores special numeric edge cases like NaN and Infinity, and highlights common non-number primitives that the function rejects.

Primitive Numbers

_.isNumber returns true for all standard JavaScript primitive numeric values. This includes:

Number Objects

Unlike the native JavaScript typeof operator—which evaluates new Number(x) as an "object"—Lodash's _.isNumber correctly identifies Number object instances.

_.isNumber(new Number(42)); // true
typeof new Number(42);      // "object"

The function checks both whether the value has a typeof of "number" and whether the internal [[Class]] or Object.prototype.toString tag matches [object Number].

Special Numeric Values

JavaScript classifies several special symbolic values under the Number type according to the IEEE 754 standard. Consequently, _.isNumber returns true for:

If your use case requires excluding NaN or infinite numbers, Lodash provides _.isFinite, which validates that a value is a number while filtering out NaN, Infinity, and -Infinity.

Values Not Accepted by _.isNumber

To prevent unexpected behavior, _.isNumber returns false for values that might look like numbers or represent numbers in other formats: