let and const support

ES6 let and const declarations are now supported when targeting ES3 and ES5.

Const

  1. const MAX = 100;
  2. ++MAX; // Error: The operand of an increment or decrement
  3. // operator cannot be a constant.

Block scoped

  1. if (true) {
  2. let a = 4;
  3. // use a
  4. }
  5. else {
  6. let a = "string";
  7. // use a
  8. }
  9. alert(a); // Error: a is not defined in this scope