constlet declarations
suggest changeUnlike var
, const
/let
are bound to lexical scope rather than function scope.
{
var x = 1 // will escape the scope
let y = 2 // bound to lexical scope
const z = 3 // bound to lexical scope, constant
}
console.log(x) // 1
console.log(y) // ReferenceError: y is not defined
console.log(z) // ReferenceError: z is not defined
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents