Js判断一个数为整数

// ES6
Number.isInteger(num);

// ES5
if (!Number.isInteger) {
  Number.isInteger = function(num) {
    return typeof num == "number" && num % 1 == 0;
  };
}

猜你喜欢

转载自blog.csdn.net/m0_37686205/article/details/89309723