You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/js/Math/Check whether a value is an...

14 lines
358 B
JavaScript

function is_Int(num) {
if (typeof num !== 'number')
return false;
return !isNaN(num) &&
parseInt(Number(num)) == num &&
!isNaN(parseInt(num, 10));
}
console.log(is_Int(23));
console.log(is_Int(4e2));
console.log(is_Int(NaN));
console.log(is_Int(23.75));
console.log(is_Int(-23));