function hoisting like var
Richard Cornford
Richard at litotes.demon.co.uk
Sun Jul 27 19:24:02 PDT 2008
Ingvar von Schoultz wrote:
> Richard Cornford wrote:
<snip>
>> {
>> 1,2,3,4,5
>> }
>>
>> - is a valid ES 3 Program (even if a pointless one); A Block
>> statement containing an Expression statement (with automatic
>> semi-colon insertion making the Expression statement
>> into - 1,2,3,4,5; -).
>>
>> eval('{1,2,3,4,5}') - results in the value 5, while -
>> eval('[1,2,3,4,5]') - returns a 5 element array.
>
> Yes. And if the rules for "{" remain unchanged, and "[" starts
> out assuming it's a literal, you get the same result with my rules.
And if I wanted that block scope this -
eval("{[\n eval('var a = 1'),eval('var b = 2'),eval('a + b')\n]}");
- will still give me an array (and side effects in the containing scope)?
More information about the Es4-discuss
mailing list