Checks if the given value is a number.

Type signature

(x?: any) => boolean

Examples

number(0 / 0);
// ⇒ false
Try in REPL
number(15.6);
// ⇒ true
Try in REPL

Questions

  • How to check if a given value is a valid number?
  • How to check if a given value is not NaN?
  • How to check if a given value is finite?

TypeScript sourceJavaScript source