判断一个字符串是否是正整数

代码:

function isNormalInteger(str) {

    var n = Math.floor(Number(str));

    return n !== Infinity && String(n) === str && n >= 0;

}

猜你喜欢

转载自www.cnblogs.com/joyzhou007/p/9238297.html