Function isAnyNumber

Checks and returns true, if value is any kind of a "real number", a good candidate for Number():

  • boxed new Number('123')
  • BigInt (eg 123456789n or BigInt('123456789'))
  • Infinity
  • a string value that represents a "real number", eg "123" or "123.456"

Anything that is resulting to a non-NaN via Number(val), is an isAnyNumber. NaN is NOT considered an isAnyNumber, as well as strings that would lead to NaN if we used Number(str).

In contrast, Lodash:

  • _.isNumber() returns true for NaN

  • _.isNumber() returns false for BigInt

and typeof..., well, who cares about legacy typeof, its next to useless!

Note: by "real number" we refer to the programming terminology, not the Mathematical "Real Numbers"!