You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IsInteger.js 514B

123456789101112131415161718192021
  1. 'use strict';
  2. var GetIntrinsic = require('../GetIntrinsic');
  3. var $Math = GetIntrinsic('%Math%');
  4. var $floor = $Math.floor;
  5. var $abs = $Math.abs;
  6. var $isNaN = require('../helpers/isNaN');
  7. var $isFinite = require('../helpers/isFinite');
  8. // https://www.ecma-international.org/ecma-262/6.0/#sec-isinteger
  9. module.exports = function IsInteger(argument) {
  10. if (typeof argument !== 'number' || $isNaN(argument) || !$isFinite(argument)) {
  11. return false;
  12. }
  13. var abs = $abs(argument);
  14. return $floor(abs) === abs;
  15. };