Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

global NaN 속성(property)은 Not-A-Number(숫자가 아님)을 나타내는 값입니다.

Property attributes of NaN
Writable no
Enumerable no
Configurable no

구문

NaN

설명

NaNglobal object의 속성입니다.

NaN의 초기값은 Not-A-Number 즉, Number.NaN 값과 같습니다.

최신 브라우저에서, NaN은 설정불가(non-configurable), 쓰기불가(non-writable) 속성입니다. 이는 그 경우가 아닐 때라도, 재정의(overriding)를 피합니다.

프로그램에서 NaN을 사용하기는 조금 드뭅니다. 그것은 Math 함수가 실패(Math.sqrt(-1)))하거나 숫자를 파싱하려 한 함수가 실패(parseInt("blabla"))했을 때 반환되는 값입니다.

NaN에 대한 테스트

NaN은 다른 NaN 값을 포함하여 다른 어떤 값과 같지 않음(==, !=, ===!==를 통해)을 비교합니다. 값이 NaN인지 가장 명확하게 결정하기 위해 Number.isNaN() 또는 isNaN()을 사용하세요. 아니면 자체 비교를 하세요: NaN 및 NaN만, 자신과 같지 않음을 비교합니다.

NaN === NaN;        // false
Number.NaN === NaN; // false
isNaN(NaN);         // true
isNaN(Number.NaN);  // true

function valueIsNaN(v) { return v !== v; }
valueIsNaN(1);          // false
valueIsNaN(NaN);        // true
valueIsNaN(Number.NaN); // true

스펙

스펙 상태 설명
ECMAScript 1st Edition (ECMA-262) Standard 초기 정의. JavaScript 1.3에서 구현됨
ECMAScript 5.1 (ECMA-262)
The definition of 'NaN' in that specification.
Standard  
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'NaN' in that specification.
Standard  
ECMAScript 2017 Draft (ECMA-262)
The definition of 'NaN' in that specification.
Draft  

브라우저 호환성

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

참조

문서 태그 및 공헌자

태그: 
 이 페이지의 공헌자: Netaras, nacyot, teoli, Gilchris
 최종 변경: Netaras,