This page was translated from English by the community.Learn more and join the MDN Web Docs community.
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 2015년 7월.
Number.NaN 속성은 Not-A-Number(숫자가 아님)를 나타냅니다.NaN과 같습니다.
In this article
시도해 보기
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 ofNumber.NaN | |
|---|---|
| 쓰기 가능 | 불가능 |
| 열거 가능 | 불가능 |
| 설정 가능 | 불가능 |
예제
>값이 숫자형인지 확인하기
js
function sanitise(x) { if (isNaN(x)) { return Number.NaN; } return x;}NaN에 대한 테스트
NaN 페이지에서NaN에 대한 테스트 를 참고하세요.
명세
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-number.nan> |