`new weirdFunction()` would `=== iter` because a constructor that returns
an object (`this`), returns that object when `new`ed - which is how
functions have worked since ES3 (or probably ES1).

On Tue, Jul 26, 2016 at 9:31 PM, Michael Theriot <
[email protected]> wrote:

> There are many things I still don't understand about iterators...
>
> ```js
> var iter = [].values();
> iter[Symbol.iterator]() === iter;
>
> var weirdFunction = iter[Symbol.iterator];
> weirdFunction.call(iter) === iter;
>
> var weirdInstance = new weirdFunction(); // what is this??
> ```
>
>
> On Mon, Jul 25, 2016 at 10:19 AM, John Lenz <[email protected]> wrote:
>
>> This seems ripe for misuse:  you don't want two "owners" for the same
>> iterator calling "next" and normally, without the Iterator interface
>> implementation, you would expect "iterator()" to always return an instance
>> of the iterator that the caller "owned".
>>
>> Can anyone provide any historical context on why this method was added to
>> the "iterator"?
>>
>> _______________________________________________
>> es-discuss mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to