Code smell? Iterator prototype has iterator method that returns "this"
Michael Theriot
michael.lee.theriot at gmail.com
Wed Jul 27 04:31:36 UTC 2016
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 <concavelenz at gmail.com> 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
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160726/5410591c/attachment.html>
More information about the es-discuss
mailing list