const isNumber = v => (typeof v === 'number' || (typeof v === 'string' && v.trim() !== '')) ? !Number.isNaN(Number(v)) : false; // isNumber('') => false // isNumber(' ') => false // isNumber('\t') => false // isNumber('$4') => false // isNumber('abc') => false // isNumber('4e') => false // isNumber(true) => false // isNumber('4e1') => true // isNumber(' 4 ') => true // isNumber(4) => true // isNumber('0') => true // isNumber(0) => true // isNumber(-0) => true
201600cookie-checkJavascript isNumber()