Number.isInteger()
Number.isInteger()
메서드는 주어진 값이 정수인지 판별합니다.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
구문
Number.isInteger(value)
매개변수
value
- 정수인지 확인하려는 값.
반환 값
주어진 값의 정수 여부를 나타내는 Boolean
.
설명
예제
Number.isInteger(0); // true Number.isInteger(1); // true Number.isInteger(-100000); // true Number.isInteger(99999999999999999999999); // true Number.isInteger(0.1); // false Number.isInteger(Math.PI); // false Number.isInteger(NaN); // 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
폴리필
Number.isInteger = Number.isInteger || function(value) {
return typeof value === "number" &&
isFinite(value) &&
Math.floor(value) === value;
};
명세
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Number.isInteger' in that specification. |
Standard | Initial definition. |
ECMAScript (ECMA-262) The definition of 'Number.isInteger' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser
같이 보기
- 메서드가 속한
Number
객체.