constlet declarations

suggest change

Unlike 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

Run in RunKit

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents