Skip to main content

This package is a simple utility to check if a value is a number.

Works with
It is unknown whether this package works with Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Browsers
JSR Score
100%
Published
3 months ago (0.1.0)

is-number

Returns true if the value is a number. comprehensive tests.

Example

isNumber(5e3); //=> true
isNumber(0xff); //=> true
isNumber(-1); //=> true
isNumber(0); //=> true
isNumber(1.337); //=> true
isNumber(-1.337); //=> true
isNumber(1e-8); //=> true
isNumber(1e-80); //=> true
isNumber(0.1); //=> true
isNumber(-0.1); //=> true
isNumber('1.1.1') //=> false
isNumber('1a') //=> false
isNumber('a') //=> false
isNumber('') //=> false
isNumber(null) //=> false
isNumber(undefined) //=> false
isNumber([]) //=> false
isNumber({}) //=> false
isNumber(NaN) //=> false
isNumber(Infinity) //=> false
isNumber(-Infinity) //=> false

Add Package

deno add @nodeteam/is-number

Import symbol

import * as mod from "@nodeteam/is-number";

Add Package

npx jsr add @nodeteam/is-number

Import symbol

import * as mod from "@nodeteam/is-number";

Add Package

yarn dlx jsr add @nodeteam/is-number

Import symbol

import * as mod from "@nodeteam/is-number";

Add Package

pnpm dlx jsr add @nodeteam/is-number

Import symbol

import * as mod from "@nodeteam/is-number";

Add Package

bunx jsr add @nodeteam/is-number

Import symbol

import * as mod from "@nodeteam/is-number";