Number.isInteger()

Determines whether the passed value is an integer.

Since ES2015 Spec ↗

Syntax

Number.isInteger(value)

Parameters

NameTypeRequiredDescription
value any Yes The value to test.

Returns

boolean — true if the value is a number with no fractional part; otherwise false.

Examples

console.log(Number.isInteger(42), Number.isInteger(42.0));
Output
true true
console.log(Number.isInteger('42'), Number.isInteger(4.2));
Output
false false

Notes

Does not coerce its argument - non-number values always return false. Very large floats that cannot represent fractions still count as integers.

Browser & runtime support

EnvironmentSince version
chrome 34
firefox 16
safari 9
edge 12
node 0.12

See also