Skip to main content

Check if a value is a number

JavaScript version

const isNumber = (value) => !isNaN(parseFloat(value)) && isFinite(value);

TypeScript version

const isNumber = (value: any): number => !isNaN(parseFloat(value)) && isFinite(value);

Comments