Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 프로그래머스
- Next 팀 프로젝트
- 내일배움캠프 프로젝트
- 자바스크립트
- REACT
- 내일배움캠프
- useState
- 파이썬 for in
- 파이썬 slice
- 파이썬 반복문
- 파이썬 enumerate
- 리액트 훅
- 타입스크립트 props
- tanstack query
- 코딩테스트
- 파이썬 for
- 리액트 공식문서
- 내배캠 프로젝트
- useEffect
- 타입스크립트 리액트
- 내일배움캠프 최종 프로젝트
- React Hooks
- 한글 공부 사이트
- 리액트
- 파이썬 딕셔너리
- 파이썬 replace
- 타입스크립트
- JavaScript
- 리액트 프로젝트
- typeScript
Archives
- Today
- Total
sohyeon kim
[JS] null과 undefined의 차이 본문
728x90
❗️null : 의도적으로 '없음'을 준 값, 의도적으로 표현할 때 사용하는 값
❗️undefined : 처음부터 없었던 값, 값이 없다는 것을 확인하는 값
typeof null // 'object'
typeof undefined // 'undefined'
null === undefined // false
null == undefined // true
null === null // true
null == null // true
!null // true
isNaN(1 + null) // false
isNaN(1 + undefined) // true
null 의 타입은 object
undefined 의 타입은 undefined
❗️변수에 null 을 할당하는 것은 이전에 참조하던 값을 더 이상 참조하지 않겠다는 것!
>> 이전에 할당되어 있던 값에 대한 참조를 제거한다는 의미이다.
이제 그 참조되지 않은 메모리 공간은 가비지 콜렉터에 의해 수집될 것!
let cup;
console.log(cup); // undefined
cup = '물';
console.log(cup); // 물
cup = null;
console.log(cup); // null
➕
let x;
console.log(x); // undefined
let y = x;
x = null;
console.log(y); // undefined
console.log(x); // null
x = y;
console.log(x); // undefined
728x90
반응형
'JavaScript' 카테고리의 다른 글
[JS] 객체 데이터 접근, 객체 메소드, 비교, 병합 (0) | 2023.12.29 |
---|---|
[JS] Optional Parameters 옵셔널 파라미터 (0) | 2023.12.29 |
[JS] 비교 연산자 ==, !=, ===, !== 동등 연산자와 일치 연산자 (0) | 2023.12.28 |
[JS] Boolean 형 변환, falsy 값 (0) | 2023.12.28 |
[JS] Boolean 불리언, && and 연산자, || or 연산자, 연산자 우선순위 (2) | 2023.12.28 |