Skip to main content

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

This package works with Node.js, DenoIt is unknown whether this package works with Bun, Cloudflare Workers, Browsers
JSR Score
100%
Published
3 months ago (0.1.0)
function isNumber

Check if the given value is a number

Examples

Example 1

isNumber(1) => true isNumber('1') => true isNumber('1.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 isNumber(0) => true isNumber(-0) => true isNumber(-1) => true isNumber(-1.1) => true isNumber(1.1) => true isNumber(1.1e3) => true isNumber(1.1e-3) => true isNumber(1.1e+3) => true

Parameters

number: any

Return Type

Add Package

deno add @nodeteam/is-number

Import symbol

import { isNumber } from "@nodeteam/is-number";

Add Package

npx jsr add @nodeteam/is-number

Import symbol

import { isNumber } from "@nodeteam/is-number";

Add Package

yarn dlx jsr add @nodeteam/is-number

Import symbol

import { isNumber } from "@nodeteam/is-number";

Add Package

pnpm dlx jsr add @nodeteam/is-number

Import symbol

import { isNumber } from "@nodeteam/is-number";

Add Package

bunx jsr add @nodeteam/is-number

Import symbol

import { isNumber } from "@nodeteam/is-number";