JavaScript (ES2026) reference · Number Methods and Properties

JavaScript Number.isInteger() Method

Return true if a value is a number with no fractional part. Strings aren't converted, so Number.isInteger("5") is false.

JavaScript (ES2026) Since ES2015

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

Number.isInteger(value)

Parameters

ParameterDescription
value The value to test.

Return value

true or false.

Examples

Integers and non-integersTry it yourself
console.log(Number.isInteger(5), Number.isInteger(5.0), Number.isInteger(5.5), Number.isInteger("5"));

Output

true true false false
Validate a quantityTry it yourself
const qty = Number("3");
console.log(Number.isInteger(qty) && qty > 0 ? "valid quantity" : "invalid");

Output

valid quantity

Version history

VersionChange
JavaScript ES2015Added

Was this page helpful?