Javascript Number isInteger() method

Description

Javascript Number isInteger() method



Number.prototype.isInteger = function ()
{
 return Number(this) === Math.floor(this);
};

Javascript Number isInteger()

Number.prototype.isInteger = function () {
    "use strict";
    var ans = false;
    if (this % 1 == 0) {
        ans = true;//from  w  w w  .j a va 2s  . com
    }
    return ans;
};

Javascript Number isInteger()

Number.prototype.isInteger = function(){
    return typeof (+this) === 'number' && this%1===0;
};



PreviousNext

Related