I\'m trying to use the isNaN
global function inside an arrow function in a Node.js module but I\'m getting this error:
[eslint] Unexpected use of \'is
@Andy Gaskell isNumber('1.2.3')
return true
, you might want to edit your answer and use Number()
in place of parseFloat()
const isEmpty = value => typeof value === 'undefined' || value === null || value === false;
const isNumeric = value => !isEmpty(value) && !Number.isNaN(Number(value));
console.log(isNumeric('5')); // true
console.log(isNumeric('-5')); // true
console.log(isNumeric('5.5')); // true
console.log(isNumeric('5.5.5')); // false
console.log(isNumeric(null)); // false
console.log(isNumeric(undefined)); // false