let & const tests

Info Code This browser Chrome 35 Chrome 35 (harmony) FF 30 WebKit IE10,11 Node 0.10 Node 0.10 harmony
Does const declare a variable?
const foo = 1;
typeof foo === 'number';
Yes Yes Yes Yes No Yes Yes
Does const declare a variable? (strict mode)
'use strict';
const foo = 1;
typeof foo === 'number';
SyntaxError: Use of const in strict mode. No No SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode. No Yes Yes
Does const make var immutable?
const foo = 1;
foo = 2;
foo === 1;
Yes Yes Yes No n/a Yes Yes
Does const make var immutable? (strict mode)
'use strict';
const foo = 1;
foo = 2;
n/a n/a n/a n/a n/a Yes Yes
Does let declare a variable?
let foo = 1;
typeof foo === 'number';
SyntaxError: Unexpected identifier SyntaxError: Illegal let declaration outside extended mode SyntaxError: missing ; before statement SyntaxError: Unexpected identifier 'foo' No Unexpected identifier Illegal let declaration outside extended mode
Does let declare a variable? (strict mode)
'use strict';
let foo = 1;
typeof foo === 'number';
SyntaxError: Unexpected strict mode reserved word No SyntaxError: let is a reserved identifier SyntaxError: Unexpected use of reserved word 'let' in strict mode No SyntaxError: Unexpected strict mode reserved word Yes
Is let block-local?
if (1) { let foo = 1; }
typeof foo === 'undefined';
n/a n/a n/a n/a Yes n/a n/a
Is let block-local? (strict mode)
'use strict';
if (1) { let foo = 1; }
typeof foo === 'undefined';
n/a Yes n/a n/a Yes n/a Yes
Does let declare non-writable variable?
if (x) {
  let foo = 1;
  let foo = '1';
  typeof foo === 'number';
}
n/a n/a n/a n/a No n/a n/a
Does let create non-writeable variable? (strict mode)
'use strict';
if (x) {
  let foo = 1;
  let foo = '1';
  typeof foo === 'number';
}
n/a n/a n/a n/a No n/a Yes
Is let block-local in type="application/javascript;version=1.8"?
{ let foo = 1; }
typeof foo === 'undefined';
Doesn't run Doesn't run Yes Doesn't run Doesn't run n/a n/a
Is let block-local in type="application/javascript;version=1.8" (strict mode)?
'use strict';
{ let foo = 1; }
typeof foo === 'undefined';
Doesn't run Doesn't run Yes Doesn't run Doesn't run n/a n/a