Thomas 'PointedEars' Lahn said:
2. In section 8.7:
"A Reference is a reference to a property of an object.
A Reference consists of two components, the base object
and the property name."
3. In section 11.4.3 (on how the "typeof" operation is evaluated):
"1. Evaluate UnaryExpression.
2. If Type(Result(1)) is not Reference, go to step 4."
That would apply to a property that does not exist.
No. A property access on an object to a property that doesn't exist
would *still* be a Reference, with a base object and a property
name. It's just that that base object doesn't have a property by that
name. The result is still a Reference.
The expression "foo.bar" (or the equivalent "foo['bar']"), where "foo"
refers to an object, and "bar" is not the name of a property of that
object, evaluates to a reference according to section 11.2.1.
In particular, it is the productions:
MemberExpression.identifier
MemberExpression[<identifier-string>Expression]
where Expression is <identifier-string>.
The evaluation of this is:
1. Evaluate MemberExpression.
Here MemeberExpression is a PrimaryExpression, which is an identifier.
The identifier is evaluated according to section 10.1.4. In this case
it gives a Reference to the object referenced by "foo".
2. Call GetValue(Result(1)).
Convert the Reference to a value. It is an object.
3. Evaluate Expression.
The expression "'bar'" is a literal and evaluates to the String 'bar'.
4. Call GetValue(Result(3)).
Just 'bar' again, since it is not a Refererence.
5. Call ToObject(Result(2)).
Result(2) is already an object, so just the same object again.
6. Call ToString(Result(4)).
Result(4) is already a string, so just the same string again.
7. Return a value of type Reference whose base object is Result(5) and
whose property name is Result(6).
That is, a Reference with base object being the object referenced
by the variable "foo", and property name "bar", even if there is
no property called "bar" on "foo"!
/L