The let keyword enables you to declare a variable with block scope.
var x = 10; // Here x is 10 { let x = 2; // Here x is 2 } // Here x is 10 |
The const keyword allows you to declare a constant, which is a variable with a fixed value that cannot be reassigned.
Constants behave similarly to let variables, but their value cannot be changed once set.
var x = 10; // Here x is 10 { const x = 2; // Here x is 2 } // Here x is 10 |