Toplevel 'let' binding can be left permanently uninitialized after an error

Jason Orendorff jason.orendorff at
Tue Sep 30 03:38:55 PDT 2014

On Mon, Sep 29, 2014 at 4:14 PM, Rick Waldron <waldron.rick at> wrote:
> Can you clarify "write"? Does this mean assignment?


> Why would assignment throw?

Assigning to an uninitialized variable is an error in ES6. A
let-binding is initialized when its declaration is evaluated. So this
is OK:

    let x;  // no Initializer, so it's initialized to undefined
    console.log(x);  // logs undefined

but this is not:

    let answer;
    function init() {
        answer = 42;  // throws ReferenceError


More information about the es-discuss mailing list