programming-examples/js/Math/Check whether a variable is numeric or not.js

10 lines
292 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function is_Numeric(num) {
return !isNaN(parseFloat(num)) && isFinite(num);
}
console.log(is_Numeric(12));
console.log(is_Numeric('abcd'));
console.log(is_Numeric('12'));
console.log(is_Numeric(' '));
console.log(is_Numeric(1.20));
console.log(is_Numeric(-200));