2.4.16.2.1 new Enumerator ([collection])

When the Enumerator constructor is called with zero or one argument the following steps are taken:

1. If collection is not present, let collection be undefined and then go to step 6.

2. If collection is an Array instance, go to step 5.

3. If collection is a host object that supports an implementation-dependent enumeration protocol, go to step 5.

4. Raise a TypeError exception.

5. The [[EnumerationState]] property of the newly created object is set to a state indicating that the enumeration is at the first item of the enumeration of collection. If collection has no enumerable items, the state will indicate that the end of the enumeration has been reached.

6. The [[Collection]] property of the newly created object is set to collection.

7. The [[Prototype]] property of the newly constructed object is set to the original Error prototype object, the one that is the initial value of Enumerator.prototype (15.12+2.3.1).

8. The [[Class]] property of the newly constructed Error object is set to "Object".

9. Return the newly constructed object.