Code smell? Iterator prototype has iterator method that returns "this"
Claude Pache
claude.pache at gmail.com
Wed Jul 27 06:52:40 UTC 2016
> Le 27 juil. 2016 à 06:31, Michael Theriot <michael.lee.theriot at gmail.com> a écrit :
>
> 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??
> ```
My intuition says: "TypeError: weirdFunction is not a constructor".
—Claude
More information about the es-discuss
mailing list