nan
-
[javascript] 숫자형에 대해서 (Infinity, NaN)Front-end/Javascript 2020. 5. 27. 14:45
자바스크립트에서 숫자형(Number)이란 숫자 형태를 가진 데이터를 의미한다. 정수, 부동소수점, 작은 수, 큰 수등 여러유형의 숫자를 숫자형(Number) 하나로 정의한다. 이외에도 자바스크립트에서는 Infinity , NaN 값이 있다. 앞으로 나올 내용은 Infinity, NaN에 더 중점을 두어 포스팅할 예정이다. Infinity 말 그대로 무한대의 숫자형을 말한다. ECMA Script3 까지는 이 변수들의 값을 수정할 수 있었지만 ES5부터 수정할 수 없는 읽기 전용 상수로 바뀌었다. 더보기 console.log(Infinity); console.log(1 / Infinity); + Infinity로 나누면 무슨 값이든 0이 된다. 결과값 더보기 Infinity 0 NaN 'Not a Numb..