Latest web development tutorials
 

JavaScript Number isInteger() Method

< JavaScript Number Reference

Example

Check whether a value is an integer:

Number.isInteger(123) //true
Number.isInteger(-123) //true
Number.isInteger(5-2) //true
Number.isInteger(0) //true
Number.isInteger(0.5) //false
Number.isInteger('123') //false
Number.isInteger(false) //false
Number.isInteger(Infinity) //false
Number.isInteger(-Infinity) //false
Number.isInteger(0 / 0) //false
Try it Yourself »

Definition and Usage

The Number.isInteger() method determines whether a value an integer.

This method returns true if the value is of the type Number, and an integer (a whole number). Otherwise it returns false.


Browser Support

Method
Number.isInteger() 19 12.0 16 9 22

Note: The Number.isInteger() method is not supported in Internet Explorer 11 and earlier versions.


Syntax

Number.isInteger(value)

Parameter Values

Parameter Description
value Required. The value to be tested

Technical Details

Return Value: A Boolean. Returns true if the value is an integer Number, otherwise it returns false
JavaScript Version: ECMAScript 6

< JavaScript Number Reference