undefined & null
let variable; // 선언 variable = 'string value'; // 할당 const initValue = '초기화된 변수'; // 선언과 동시에 할당 선언과 할당 그리고 선언과 동시에 할당 let variable; // 선언 const nullValue = null; // null을 지정 (빈값임을 명시적으로 지정) variableundefined initValuenull 비어있는 값에 대한 처리를 해야하기 때문에 undefined 와 null 을 자신에게 맞게 사용하여야 한다. null과 undefined 차이 undefined 은 변수를 선언하고 값을 할당하지 않은 상태, null 은 변수를 선언하고 빈 값을 할당한 상태(빈 객체)이다. 즉, undefined 는 자료형이 없는 ..
JavaScript
2022. 5. 23. 03:35