Checks if value is either a strict number OR BigInt OR Infinity, excluding only NaNs & boxed new Number('123').
BigInt
Infinity
NaN
new Number('123')
Why? Because typeof NaN === 'number', _.isNumber(NaN) && _.isNumber(Number('foo')) are both true!
typeof NaN === 'number'
_.isNumber(NaN)
_.isNumber(Number('foo'))
Also, _.isNumber() returns false for BigInt, but it's just a number!
_.isNumber()
false
Infinity is a number too, in isNumber terms.
isNumber
z.isAnyNumber()
z.isStrictNumber()
Checks if value is either a strict number OR
BigInt
ORInfinity
, excluding onlyNaN
s & boxednew Number('123')
.Why? Because
typeof NaN === 'number'
,_.isNumber(NaN)
&&_.isNumber(Number('foo'))
are both true!Also,
_.isNumber()
returnsfalse
forBigInt
, but it's just a number!Infinity
is a number too, inisNumber
terms.See
z.isAnyNumber()
for the most inclusive, less strict check (incl string numbers!)z.isStrictNumber()
for the most strict check, 'real' numbers only!