JavaScript Number.isInteger() Method
Example
Check whether the parameter is an integer:
Number
.
isInteger
(
123
)
;
Number
.
isInteger
(
123
)
;
Number
.
isInteger
(
'
123
'
)
;
Number
.
isInteger
(
4
2
)
;
Number
.
isInteger
(
4
/
2
)
;
Number
.
isInteger
(
5
2
)
;
Number
.
isInteger
(
5
/
2
)
;
Try it »
Definition and Usage
The isInteger() function is used to check whether the specified argument is an integer, returning true if it is an integer, otherwise false.
Number.isInteger(0); // true
Number.isInteger(1); // true
Number.isInteger(-100000); // true
Number.isInteger(0.1); // false
Number.isInteger(Math.PI); // false
Number.isInteger(Infinity); // false
Number.isInteger(-Infinity); // false
Number.isInteger("10"); // false
Number.isInteger(true); // false
Number.isInteger(false); // false
Number.isInteger([1]); // false
Browser support
Number.isInteger() is a new feature of ECMAScript 6 (ES6).
Basically, the latest browser versions support ES6 (JavaScript 2015).
Number.isInteger() is not supported in Internet Explorer 11 and earlier browser versions.
| Chrome | Edge | Firefox | Safari | Opera |
| Yes | Yes | Yes | Yes | Yes |
Syntax
Number.isInteger(value)
Parameter value
| Parameters | Description |
|---|---|
| value | The value to be tested. |
Return Value
| Type | Description |
|---|---|
| Boolean | Returns true if it is an integer, otherwise returns false. |
Technical Details
| JavaScript version: | ECMAScript 6 |
|---|
More examples
Example
Check whether the parameter is an integer:
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 »
JavaScript Number object