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
valueRequired.
The value to be tested.

Return Value

Type Description
A booleantrue 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 since June 2017:

Chrome 51 Edge 15 Firefox 54 Safari 10 Opera 38
May 2016 Apr 2017 Jun 2017 Sep 2016 Jun 2016

Number.isInteger() is not supported in Internet Explorer.


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.