Friday, 22 January 2016

Post 40: How to check for integer in JavaScript

In JavaScript there is no better way:

var isInt = function (x) {
        return (typeof Number(x) === 'number') && (x % 1 === 0);
      }
Tweet