目录

JavaScript Number isInteger()

Examples

Are these integers?

Number.isInteger(123);
Number.isInteger(-123);
Number.isInteger('123');
Try it Yourself »
Number.isInteger(4-2);
Number.isInteger(4/2);
Number.isInteger(5-2);
Number.isInteger(5/2);
Try it Yourself »

More examples below


Description

The Number.isInteger() method returns true if a value is an integer of the datatype Number.

Otherwise it returns false.


Syntax

Number.isInteger( value)

Parameters

Parameter Description
value Required.
The value to be tested.

Return Value

Type Description
A boolean true if the value is an integer of the datatype Number.
Otherwise false.

More Examples

Are these integers?

Number.isInteger(0);
Number.isInteger(0/0);
Number.isInteger(0.5);
Number.isInteger(false);
Number.isInteger(NaN);
Number.isInteger(Infinity);
Number.isInteger(-Infinity);
Try it Yourself »


Browser Support

Number.isInteger() is an ECMAScript6 (ES6) feature.

ES6 (JavaScript 2015) is supported in all modern browsers:

Chrome Edge Firefox Safari Opera
Yes Yes Yes Yes Yes

Number.isInteger() is not supported in Internet Explorer 11 (or earlier).