isNumber
Checks if the given argument is a number.
- Use
typeof
to check if a value is classified as a number primitive. - To safeguard against
NaN
, check ifval === val
(asNaN
has atypeof
equal tonumber
and is the only value not equal to itself).