1. var
- 재선언 가능
- 재할당 가능
var test = "a";
console.log("test : ", test); // test : a
var test = "b";
console.log("test : ", test); // test : b
2. let
- 재선언 불가능
- 재할당 가능
let test = "a";
console.log("test : ", test); // test : a
let test = "b";
console.log("test : ", test); // already 에러 발생
test = "c"
console.log("test : ", test); // test : c
3. const
- 재선언 불가능
- 재할당 불가능 : 일회용 변수
let test = "a";
console.log("test : ", test); // test : a
let test = "b";
console.log("test : ", test); // already 에러 발생
test = "c"
console.log("test : ", test); // constant variable 에러 발생
반응형
'Client Side' 카테고리의 다른 글
async & await (0) | 2023.01.27 |
---|---|
FileReader 이미지 미리보기 (0) | 2023.01.26 |
Ajax Option (0) | 2023.01.26 |
$.extend() - merge기능의 함수 (0) | 2023.01.20 |
Drag And Drop 정렬 변경 (0) | 2023.01.20 |