Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/number/index.js>isNumeric

A JavaScript extension package for building strong and modern applications.
Latest
function isNumeric
import { isNumeric } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/number/index.js";

Returns true if the given value is a numeric value, false otherwise. A numeric value is a number, a bigint, or a string that can be converted to a number or bigint.

NOTE: NaN is not considered numeric.

Examples

Example 1

import { isNumeric } from "@ayonli/jsext/number";

console.log(isNumeric(42)); // true
console.log(isNumeric(42n)); // true
console.log(isNumeric("42")); // true

console.log(isNumeric(NaN)); // false
console.log(isNumeric(42n, true)); // false
console.log(isNumeric("42", true)); // false

Parameters

value

Only returns true when the value is of type number.

optional
strict = [UNSUPPORTED]