undeclared
-
빈 값 (null, undefined, undeclared, NaN)개발공부/JavaScript 2023. 12. 27. 16:26
오늘은 자바스크립트에서 빈 값을 표현하는 null, undefined, undeclared, NaN에 대해 자세히 알아보고자 한다. 모두 빈 값은 표현하지만 각각 다른 의미를 가지고 있어 사용할 때 주의해야 한다. null 명시적으로 값이 없음을 나타내는 값 (= 빈 값을 의미) 변수가 존재하지만 값이 지정되지 않았거나 비어 있는 경우에 사용 undefined 값이 할당되지 않은 변수 또는 객체의 속성에 접근 했을 때 나타는 값 (= 정의되지 않음) 변수가 선언되었지만 초기화 되지 않은 경우 또는 함수에서 값을 반환하지 않은 경우 등에서 발생 undeclared 자바스크립트에서 사용되지 않음 선언되지 않은 변수를 나타내는 맥락에서 사용 됨. 즉, 변수를 선언하지 않고 사용하면 해당 변수는 undeclar..