1、取余数判断,整数除以1都为0
function isInteger(obj) {
return typeof obj === 'number' && obj%1 === 0
}
2、使用Math.round、Math.ceil、Math.floor判断
function isInteger(obj) {
return Math.floor(obj) === obj
}
3、ES6提供了Number.isInteger
parseInt(1000000000000000000000, 10) === 1000000000000000000000 //false