Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 613 Bytes

07__Let__Const.md

File metadata and controls

24 lines (20 loc) · 613 Bytes
title
Let + Const

Block-scoped binding constructs. let is the new var. const is single-assignment. Static restrictions prevent use before assignment.

function f() {
  {
    let x;
    {
      // okay, block scoped name
      const x = "sneaky";
      // error, const
      x = "foo";
    }
    // error, already declared in block
    let x = "inner";
  }
}

More MDN info: let statement, const statement