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