function f() { console.log(a); const a = 1; console.log(a); }
...actually returns this:
undefined 1
So you get partially compile-time semantics (you can't assign to a) but partially run-time semantics (a only gets its value when initialised). Simply propagating the value of a's initialiser to all places where the variable is used is wrong, as this behaviour's required by the spec.
> ReferenceError: can't access lexical declaration `a' before initialization
> The variables are created when their containing Lexical Environment is instantiated but may not be accessed in any way until the variable’s LexicalBinding is evaluated.
I.e. given a variable declared with `const`, you may not access it before it is set.
[1] http://people.mozilla.org/~jorendorff/es6-draft.html#sec-let...