Performance concern with let/const

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Sep 17 10:51:30 PDT 2012


On Sep 17, 2012, at 12:37 PM, Luke Hoban wrote:

> 
> These are good questions.  Paul will be attending the TC39 meeting this week, and can likely talk to specific details.   High level though, we statically eliminate the TDZ checks for references to 'let' within the same closure body as the declaration. 
> 

The other major check that I would expect to be significant, is whether a inner function that references an outer TDZ binding is (potentially) called before initialization of the binding.  EG:

{
    function f(){return x}
    f();   //TDZ check of x in f can not be eliminated
    let x=1;
}

{
    function f(){return x}
    let x=1;  //TDZ check of x in f should be eliminated
    f();   
}

Allen




More information about the es-discuss mailing list