A quick question about
http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7#let_statement
The article says "The completion value of the let statement is the
completion value of the block". I'm not sure what is this supposed to
mean. This would make some sense if |let| could be used in expression
context (like alert(let (a=1) { ... })), but it seems it can't be used
like that.
Sheppy says this sentence was copied from the es4 specification (proposal?).
I'm going to remove this sentence from the article, but wanted to
check if I'm missing something important first.
Nickolay
Consider:
js> let (a = 1) { a }
1
In this case, in the JS shell, we have a let statement whose completion
value (the value of the statement) is the completion value of the block.
Also, I'm not sure what you mean "it can't be used like that" in your
example above. Your example shows a let expression -- you can't create a
let statement in the middle of another statement! Because of this, the
curly braces are parsed as an object initializer. You can also do:
js> print(let (a = 1) a)
1
which seems closer to what you want.
--
Blake Kaplan
eval() is another case when it's visible to a JS programmer.
> Also, I'm not sure what you mean "it can't be used like that" in your
> example above. Your example shows a let expression -- you can't create a
> let statement in the middle of another statement! Because of this, the
> curly braces are parsed as an object initializer. You can also do:
>
> js> print(let (a = 1) a)
> 1
>
> which seems closer to what you want.
Yeah, but the text about the completion value was in the "let
statement" section of the article (with a section on let expressions
below), so I tried to put a statement inside a statement to see the
completion value :)
I think I'm less confused now. Thanks again.
Nickolay