자바스크립트의 Null
null
은 'nothing'을 의미한다. 어떤한 값이 있어야하지만 있지 않은 상태이다.
자바스크립트에서 null
의 데이터 타입은 object
이다.
null
의 데이터 타입이 object
인 것은 자바스크립트의 일종의 버그라고 할 수 있다.
Primitive Data Type(원시 타입)의 종류(4가지)
typeof
연산자를 사용하면 primitive types 중 하나를 반환한다.
- string
- number
- boolean
- undefined
Undefined
값이 없는 변수는 undefined
이며, 타입도 undefined
이다.
Undefined 와 Null의 차이
undefined
와 null
의 값은 같지만 타입은 다르다.
typeof undefined // undefined
typeof null // object
null === undefined // false
null == undefined // true
요약 / 기타
null
의 데이터 타입 : object
NaN
의 데이터 타입 : numer
참고 자료
반응형