The precise meaning of "For each named own enumerable property name P of O"
Allen.Wirfs-Brock at microsoft.com
Wed Aug 12 14:33:52 PDT 2009
ES5 section 12.6 (for-in statement) says:
The mechanics and order of enumerating the properties (step 6.a in the first algorithm, step 7.a in the second) is not specified. 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 guaranteed not to be visited in the active enumeration.
ES3 says pretty much the same thing with minor wording tweaks.
>From: es-discuss-bounces at mozilla.org [mailto:es-discuss-
>bounces at mozilla.org] On Behalf Of Jeff Walden
>Sent: Wednesday, August 12, 2009 1:04 PM
>To: es-discuss at mozilla.org
>Subject: The precise meaning of "For each named own enumerable property
>name P of O"
>What is the behavior when the body of the loop may have side effects?
>There are a number of these for the Object.* hooks, but I'm most
>specifically considering Object.defineProperties, in the case when some
>getter executed in the body of that loop (also in ToPropertyDescriptor)
>results in a new property being added, a future property being removed,
>a property being readded with the same name (does it attempt to define
>the property twice?) -- all the usual enumeration hazards, but most
>particularly the last one because of potential weirdness of defining the
>same property twice with conflicting attributes between the two property
>descriptors (if the appropriate behavior were specified to trigger
>es-discuss mailing list
>es-discuss at mozilla.org
More information about the es-discuss