CKTIS / JavaScript
Number.isInteger: an integral Number without coercion
Number.isInteger returns true when its argument is a finite Number with no fractional part, without converting other types.
Version: ECMAScript 2015 onward; example target: Node.js 24.22.2
Syntax
Number.isInteger(number)Number.isInteger(value) returns true for a finite value of Number type whose mathematical value is integral. This includes +0, -0, and negative integers; NaN, Infinity, -Infinity, and values with a represented fractional part produce false. A missing argument also produces false.
The method does not apply ToNumber, so "3", BigInt, Symbol, null, booleans, ordinary objects, and new Number(3) produce false without conversion. The test sees the already stored binary64 value: a literal with a tiny fractional part can have rounded to an integer first. Also, Number.isInteger(2 ** 53) is true even though that value is not a safe integer; use Number.isSafeInteger for that guarantee.
The method has existed since ECMAScript 2015 and is not a constructor. The example validates a page number and page size as integers within explicit bounds, then selects records c d. For indexes, counters, and identifiers, combine the integer test with domain limits; when exact consecutive integers matter, require the safe range as well.
Examples
function page(records, pageNumber, pageSize) {
if (!Number.isInteger(pageNumber) || pageNumber < 1 || pageNumber > 1000) return [];
if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100) return [];
const start = (pageNumber - 1) * pageSize;
return records.slice(start, start + pageSize);
}
console.log(page(["a", "b", "c", "d", "e"], 2, 2).join(" "));
console.log(Number.isInteger(3), Number.isInteger(3.2), Number.isInteger("3"));
console.log(Number.isInteger(-0), Number.isInteger(2 ** 53), Number.isSafeInteger(2 ** 53));Result
c d true false false true true false
Number.isInteger → pagination validation and the safe-integer boundary