Skip to main content

isNumber

Validates if the supplied input is a number (finite or infinite). To make sure the supplied number is a valid finite number, use isNumberFinite.

Signature

isNumber(input: any): boolean

Parameters

NameTypeOptionalDescription
inputanyNoInput to validate.

Return value

Returns true if the input is a number.

Example

import { isNumber } from "@tripetto/runner";

isNumber(1); // Returns `true`
isNumber(Infinity); // Returns `true`
isNumber(NaN); // Returns `false`
isNumber("1"); // Returns `false`