Block-scoped

#Let

function fn () {
  let x = 0
  if (true) {
    let x = 1 // only inside this `if`
  }
}

#Const

const a = 1

let is the new var. Constants (const) work just like let, but cannot be reassigned. See: Let and const

Comments