Checks if the given argument is a number.
typeof
to check if a value is classified as a number primitive.NaN
, check if val === val
(as NaN
has a typeof
equal to number
and is the only value not equal to itself).const isNumber = val => typeof val === 'number' && val === val;
isNumber(1); // true
isNumber('1'); // false
isNumber(NaN); // false
JavaScript, Type
Checks if the given argument is an async
function.
JavaScript, Type
Checks if the given argument is a generator function.
JavaScript, Type
Checks if the given argument is a function.