如何判断一个数值为整数
Issue 欢迎在 Gtihub Issue 中回答此问题: Issue 641 (opens in a new tab)
Author 回答者: shfshanyue (opens in a new tab)
// ES6
Number.isInteger(num);
// ES5
if (!Number.isInteger) {
Number.isInteger = function (num) {
return typeof num == "number" && num % 1 == 0;
};
}