On 2/4/11, mcot <[email protected]> wrote:
> Hi.  I am still reading up on this but here are some more tests I have
> run:
>
> console.log(typeof(foo) === 'undefined');     // true  -- doesn't raise
> reference error.
> foo;                                                          // reference 
> error even without the call to console.log

Well you're leading me right through the spec.
http://ecma262-5.com/ELS5_HTML.htm#Section_11.4.3

| 11.4.3   The typeof Operator
| The production UnaryExpression : typeof UnaryExpression is
| evaluated as follows:
|
|
| # Let val be the result of evaluating UnaryExpression.
| # If Type(val) is Reference, then
|
|   1. If IsUnresolvableReference(val) is true, return "undefined".

and so `foo` is of type reference, and since the base object is
undefined, IsUnresolvableReference results true, and the result is
undefiend.

And as for the grouping operator that you used to surround foo, that
doesn't apply GetValue either.

typeof foo;
typeof(foo);

do the same thing. And ditto with
delete foo;
delete(foo);
That's what it says in "11.1.6   The Grouping Operator"
http://ecma262-5.com/ELS5_HTML.htm#Section_11.1.6
And it works the same way in EcmaScript Ed 3.
-- 
Garrett

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to