On 2006-04-10, at 19:18 EDT, Adam Wolff wrote:
> this works in laszlo (swf)
>
> var myobject = { x : 1 , y : 2 };
> for( var k in myobject ){
> myobject[ k + "a" ] = 3;
> }
> //now myobject == { x : 1 , y : 2 , xa : 3 , ya : 3 }
>
> will this always have the same behavior per the language spec? that
> is, is
> enumeration of an object's keys in a for loop always a stack operation
> that happens before the contents of a for loop?
>
> A
The spec says you cannot rely on that:
> The mechanics of enumerating the properties (step 5 in the first
> algorithm, step 6 in the second) is implementation
> dependent. The order of enumeration is defined by the object.
> Properties of the object being enumerated may be
> deleted during enumeration. If a property that has not yet been
> visited during enumeration is deleted, then it will not
> be visited. If new properties are added to the object being
> enumerated during enumeration, the newly added
> properties are not guaranteed to be visited in the active enumeration.
> Enumerating the properties of an object includes enumerating
> properties of its prototype, and the prototype of the
> prototype, and so on, recursively; but a property of a prototype is
> not enumerated if it is “shadowed” because some
> previous object in the prototype chain has a property with the same
> name.
[ECMAScript Language Specification Edition 3 24-Mar-00 p. 74]
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user