You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The iterator's `throw` and `return` methods are *null* and are never invoked. The iterator's `next` method processes object properties to determine whether the property key should be returned as an iterator value. Returned property keys do not include keys that are Symbols. Properties of the target object may be deleted during enumeration. A property that is deleted before it is processed by the iterator's `next` method is ignored. If new properties are added to the target object during enumeration, the newly added properties are not guaranteed to be processed in the active enumeration. A property name will be returned by the iterator's `next` method at most once in any enumeration.</p>
17992
18002
<p>Enumerating the properties of the target 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 processed if it has the same name as a property that has already been processed by the iterator's `next` method. The values of [[Enumerable]] attributes are not considered when determining if a property of a prototype object has already been processed. The enumerable property names of prototype objects must be obtained by invoking EnumerateObjectProperties passing the prototype object as the argument. EnumerateObjectProperties must obtain the own property keys of the target object by calling its [[OwnPropertyKeys]] internal method. Property attributes of the target object must be obtained by calling its [[GetOwnProperty]] internal method.</p>
18003
+
<p>In addition, if neither _O_ nor any object in its prototype chain is a Proxy exotic object, Integer-Indexed exotic object, Module Namespace exotic object, or implementation provided exotic object, then the iterator must behave as would the iterator given by CreateForInIterator(_O_) until one of the following occurs:</p>
18004
+
<ul>
18005
+
<li>the value of the [[Prototype]] internal slot of _O_ or an object in its prototype chain changes,</li>
18006
+
<li>a property is removed from _O_ or an object in its prototype chain,</li>
18007
+
<li>a property is added to an object in _O_'s prototype chain, or</li>
18008
+
<li>the value of the [[Enumerable]] attribute of a property of _O_ or an object in its prototype chain changes.</li>
18009
+
</ul>
18010
+
17993
18011
<emu-note>
17994
-
<p>The following is an informative definition of an ECMAScript generator function that conforms to these rules:</p>
18012
+
<p>Hosts are not required to implement the algorithm in <emu-xref href="#sec-%foriniteratorprototype%.next"></emu-xref> directly. They may choose any implementation whose behavior will not deviate from that algorithm unless one of the constraints in the previous paragraph is violated.</p>
18013
+
<p>The following is an informative definition of an ECMAScript generator function that conforms to these rules:</ins></p>
The list of exotic objects for which implementations are not required to match CreateForInIterator was chosen because implementations historically differed in behavior for those cases, and agreed in all others.
18035
+
</emu-note>
18036
+
</emu-clause>
18037
+
18038
+
<emu-clause id="sec-for-in-iterator-objects">
18039
+
<h1>For-In Iterator Objects</h1>
18040
+
<p>A For-In Iterator is an object that represents a specific iteration over some specific object. For-In Iterator objects are never directly accessible to ECMAScript code; they exist soley to illustrate the behavior of EnumerateObjectProperties.</p>
<p>The abstract operation CreateForInIterator with argument _object_ is used to create a For-In Iterator object which iterates over the own and inherited enumerable string properties of _object_ in a specific order. It performs the following steps:</p>
18045
+
<emu-alg>
18046
+
1. Assert: Type(_object_) is Object.
18047
+
1. Let _iterator_ be ObjectCreate(%ForInIteratorPrototype%, « [[Object]], [[ObjectWasVisited]], [[VisitedKeys]], [[RemainingKeys]] »).
18048
+
1. Set _iterator_.[[Object]] to _object_.
18049
+
1. Set _iterator_.[[ObjectWasVisited]] to *false*.
18050
+
1. Set _iterator_.[[VisitedKeys]] to a new empty List.
18051
+
1. Set _iterator_.[[RemainingKeys]] to a new empty List.
1. Assert: _O_ has all of the internal slots of a For-In Iterator Instance (<emu-xref href="#sec-properties-of-for-in-iterator-instances"></emu-xref>).
18073
+
1. Let _object_ be _O_.[[Object]].
18074
+
1. Let _visited_ be _O_.[[VisitedKeys]].
18075
+
1. Let _remaining_ be _O_.[[RemainingKeys]].
18076
+
1. Repeat,
18077
+
1. If _O_.[[ObjectWasVisited]] is *false*, then
18078
+
1. Let _keys_ be ? _object_.[[OwnPropertyKeys]]().
18079
+
1. For each _key_ of _keys_ in List order, do
18080
+
1. If Type(_key_) is String, then
18081
+
1. Append _key_ to _remaining_.
18082
+
1. Set _O_.[[ObjectWasVisited]] to *true*.
18083
+
1. Repeat, while _remaining_ is not empty,
18084
+
1. Remove the first element from _remaining_ and let _r_ be the value of the element.
18085
+
1. If there does not exist an element _v_ of _visited_ such that SameValue(_r_, _v_) is *true*, then
18086
+
1. Let _desc_ be ? _object_.[[GetOwnProperty]](_r_).
18087
+
1. If _desc_ is not *undefined*, then
18088
+
1. Append _r_ to _visited_.
18089
+
1. If _desc_.[[Enumerable]] is *true*, return CreateIterResultObject(_r_, *false*).
18090
+
1. Set _object_ to ? _object_.[[GetPrototypeOf]]().
18091
+
1. Set _O_.[[Object]] to _object_.
18092
+
1. Set _O_.[[ObjectWasVisited]] to *false*.
18093
+
1. If _object_ is *null*, return CreateIterResultObject(*undefined*, *true*).
<p>For-In Iterator instances are ordinary objects that inherit properties from the %ForInIteratorPrototype% intrinsic object. For-In Iterator instances are initially created with the internal slots listed in <emu-xref href="#table-for-in-iterator-instance-slots"></emu-xref>.</p>
18101
+
<emu-table id="table-for-in-iterator-instance-slots" caption="Internal Slots of For-In Iterator Instances">
18102
+
<table>
18103
+
<tbody>
18104
+
<tr>
18105
+
<th>
18106
+
Internal Slot
18107
+
</th>
18108
+
<th>
18109
+
Description
18110
+
</th>
18111
+
</tr>
18112
+
<tr>
18113
+
<td>
18114
+
[[Object]]
18115
+
</td>
18116
+
<td>
18117
+
The Object value whose properties are being iterated.
18118
+
</td>
18119
+
</tr>
18120
+
<tr>
18121
+
<td>
18122
+
[[ObjectWasVisited]]
18123
+
</td>
18124
+
<td>
18125
+
*true* if the iterator has invoked [[OwnPropertyKeys]] on [[Object]], *false* otherwise.
18126
+
</td>
18127
+
</tr>
18128
+
<tr>
18129
+
<td>
18130
+
[[VisitedKeys]]
18131
+
</td>
18132
+
<td>
18133
+
A list of String values which have been emitted by this iterator thus far.
18134
+
</td>
18135
+
</tr>
18136
+
<tr>
18137
+
<td>
18138
+
[[RemainingKeys]]
18139
+
</td>
18140
+
<td>
18141
+
A list of String values remaining to be emitted for the current object, before iterating the properties of its prototype (if its prototype is not *null*).
0 commit comments