Ah, yes, I meant reference error.

I just realized maybe my mental model is wrong:

Is it correct that this is the scope chain for a "for" loop?

top scope
  for condition scope
    for statement scope

Statement can reference variables defined in condition, but not the other way 
around?

> On Apr 17, 2015, at 11:15 PM, Caitlin Potter <[email protected]> wrote:
> 
> er, to add to that, “a” shouldn’t be undefined during the while condition, 
> this should throw — it’s a reference error
> 
> 
>> On Apr 17, 2015, at 11:10 AM, Caitlin Potter <[email protected]> wrote:
>> 
>> Is there a language where lexically scoped variables declared in a block are 
>> accessible outside of that block? Java, C, C#, rust, Python, etc, will not 
>> let you do this. I’m not sure this is a gotcha for most software developers
>> 
>>> On Apr 17, 2015, at 10:57 AM, Glen Huang <[email protected]> wrote:
>>> 
>>> ```js
>>> do {
>>> let a = 1;
>>> } while (a);
>>> ```
>>> is "a" undefined in the while condition? This seems like a gotcha.
>>> 
>>> 
>>> _______________________________________________
>>> es-discuss mailing list
>>> [email protected]
>>> https://mail.mozilla.org/listinfo/es-discuss
>> 
> 

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to