const abc = "test";
function example() {
console.log("inside_block: ", abc);
}
example();
console.log("outside_block: ", abc);
inside_block: test
outside_block: test
const abc;
abc = "test"
function example() {
console.log("inside_block: ", abc);
}
example();
console.log("outside_block: ", abc);
SyntaxError: Missing initializer in const declaration
const abc = "test";
function example() {
const abc = 123;
console.log("inside_block: ", abc);
}
example();
console.log("outside_block: ", abc);
inside_block: 123
outside_block: test
const abc = "test";
function example() {
abc = 123;
console.log("inside_block: ", abc);
}
example();
console.log("outside_block: ", abc);
TypeError: Assignment to constant variable.