Number.NaN
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Number.NaN
속성은 Not-A-Number(숫자가 아님)를 나타냅니다. NaN
과 같습니다.
시도해보기
function clean(x) {
// eslint-disable-next-line use-isnan
if (x === Number.NaN) {
// Can never be true
return null;
}
if (isNaN(x)) {
return 0;
}
}
console.log(clean(Number.NaN));
// Expected output: 0
정적 속성이므로 접근하기 위해 Number
객체를 생성할 필요는 없습니다. (Number.NaN
사용)
Property attributes of Number.NaN | |
---|---|
쓰기 가능 | 불가능 |
열거 가능 | 불가능 |
설정 가능 | 불가능 |
예제
값이 숫자형인지 확인하기
js
function sanitise(x) {
if (isNaN(x)) {
return Number.NaN;
}
return x;
}
NaN에 대한 테스트
NaN
페이지에서 NaN에 대한 테스트 를 참고하세요.
명세
Specification |
---|
ECMAScript® 2025 Language Specification # sec-number.nan |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
NaN |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.