"In programs and classes let does not create properties on the global object like var does; instead, it creates properties in an implicit block created for the evaluation of statements in those contexts."
https://developer.mozilla.org/en/New_in_JavaScript_1.7
but in Fx8 the following does create a "window.a"
<script type="application/javascript;version=1.8">
let a = 1;
</scipt>
al...@yahoo.com wrote:
> "In programs and classes let does not create properties on the global object
> like var does; instead, it creates properties in an implicit block created
> for the evaluation of statements in those contexts."
> https://developer.mozilla.org/en/New_in_JavaScript_1.7
> but in Fx8 the following does create a "window.a"
> <script type="application/javascript;version=1.8">
> let a = 1;
> </scipt>
It might be that the documentation is wrong, at least I tried Rhino and it shows the same behaviour:
Rhino 1.7 release 3 2011 05 09
js> 'x' in this
false
js> let x = 1;
js> 'x' in this
true
> al...@yahoo.com wrote:
>> "In programs and classes let does not create properties on the global >> object
>> like var does; instead, it creates properties in an implicit block >> created
>> for the evaluation of statements in those contexts."
>> https://developer.mozilla.org/en/New_in_JavaScript_1.7
>> but in Fx8 the following does create a "window.a"
>> <script type="application/javascript;version=1.8">
>> let a = 1;
>> </scipt>
There is a spec, upcoming, in ES.next (ES6?) -- but the SpiderMonkey
implementation pre-dates this. I suspect it will be brought into alignment
in the not-too-distant future.
As for not creating props on global - avoiding that is uglier than the
alternative IMO.
Wes
On 8 November 2011 16:15, <al...@yahoo.com> wrote:
>>> but in Fx8 the following does create a "window.a"
>>> <script type="application/javascript;version=1.8">
>>> let a = 1;
>>> </scipt>
>> It might be that the documentation is wrong
> Is there a spec?
> Who should be asked what's expected here?
I have not been following this group respectively mailing list closely. There was a time when developers of Spidermonkey read here and reacted so you might want to wait some more time whether you get some more qualified response.
As an alternative, https://developer.mozilla.org/en/SpiderMonkey mentions an IRC channel irc://irc.mozilla.org/jsapi where you could try to get a faster response.
> "In programs and classes let does not create properties on the global > object like var does; instead, it creates properties in an implicit block > created for the evaluation of statements in those contexts."
> https://developer.mozilla.org/en/New_in_JavaScript_1.7
> but in Fx8 the following does create a "window.a"
> <script type="application/javascript;version=1.8">
> let a = 1;
> </scipt>
> "In programs and classes let does not create properties on the global object
> like var does; instead, it creates properties in an implicit block created
> for the evaluation of statements in those contexts."https://developer.mozilla.org/en/New_in_JavaScript_1.7
> but in Fx8 the following does create a "window.a"
> <script type="application/javascript;version=1.8">
> let a = 1;
> </scipt>
Strange. The docs are totally wrong here. I've fixed them -- thanks
for bringing it up!