programming-examples/js/Vre2/Validate whether a given value is number or not.js

10 lines
280 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function is_number(value)
{
return !isNaN(value) && toString.call(value) === '[object Number]';
}
console.log(is_number(NaN));
console.log(is_number(42.32));
console.log(is_number(72));