JavaScript: Number.isInteger

By Xah Lee. Date: .

Number.isInteger ( number )

Returns true if number is a integer.

console.log ( Number.isInteger ( 0 ) ); // true
console.log ( Number.isInteger ( 0.0000 ) ); // true

console.log ( Number.isInteger ( 0.00000000000000001 ) ); // false
console.log ( Number.isInteger ( Infinity ) ); // false
console.log ( Number.isInteger ( NaN ) ); // false

console.log ( Number.isInteger ( new Number (3) ) ); // false
console.log ( Number.isInteger ( new Number (3).valueOf ( ) ) ); // true

Reference

ECMAScript® 2016 Language Specification#sec-number.isinteger

Number Topic


  1. JavaScript: Number Object
  2. JavaScript: Number Constructor
  3. JavaScript: Number.prototype
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.