Undefiend 와 Null

Nari·2023년 7월 25일

FE

목록 보기
1/4
post-thumbnail

매개변수 심화 중 undefined이 출력되는 부분 발견!

function plus(a,b){
  console.log(a+b);
};

let a = plus(10, 20);
console.log(a);

'값이 없다' 라는 부분에서는 동일하지만
null과 어떤 차이가 있는지 궁금했다🤔




[ undefend과 null ]
두 값의 의미는 값이 없다 라는 부분에서 비슷하지만,
각각이 사용되는 목적과 장소가 다름.

undefiend : 변수는 존재하나,
어떠한 값으로도 할당되지 않아 자료형이 '정해지지 않은(undefined)' 상태입니다.

null : 변수는 존재하나, null 로 (값이) 할당된 상태.
즉 null은 자료형이 '정해진(defined)' 상태입니다.

참고출처: https://siyoon210.tistory.com/148

profile
Hello world!

0개의 댓글