2.2.2 const를 이용한 선언
const를 이용해 재할당이 불가능한 블록 레벨 변수를 선언할 수 있다.
function notOk() {
const a = 1;
a = 2;
}
notOk(); // TypeError: Assignment to constant variable.function foo() {
console.log(a);
const a = 3;
}
foo(); // ReferenceError: a is not definedfunction ok() {
const a = 3;
console.log(a);
}
function notOk() {
const a;
a = 3;
console.log(a);
}
ok(); // 3
notOk(); // SyntaxError: Missing initializer in const declarationLast updated