-
-
Notifications
You must be signed in to change notification settings - Fork 0
number number
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isNumber(it: unknown): it is number;
Checks if the given value is a number. This includes all numbers, without
distinguishing between NaN
, Infinity
, and other special values.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a number, false
otherwise.
Primitives
import { isNumber } from "jsr:@nick/is/number";
isNumber("123"); // false
isNumber(123); // true
import { isNumber } from "jsr:@nick/is/number";
const x: unknown = 123;
if (isNumber(x)) {
console.log(x + 1);
// ^? const x: number
}