Code smell? Iterator prototype has iterator method that returns "this"
Caitlin Potter
caitpotter88 at gmail.com
Wed Jul 27 23:08:10 UTC 2016
That bug was filed today/yesterday and fixed, thanks to this thread :)
> On Jul 27, 2016, at 7:02 PM, Michael Theriot <michael.lee.theriot at gmail.com> wrote:
>
> At least in Chrome, new weirdFunction() !== iter nor does it throw a TypeError... but maybe that's a bug...
>
>> On Wed, Jul 27, 2016 at 10:12 AM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
>>
>>>> On Jul 26, 2016, at 11:52 PM, Claude Pache <claude.pache at gmail.com> wrote:
>>>>
>>>>
>>>> var weirdInstance = new weirdFunction(); // what is this??
>>>> ```
>>>
>>> My intuition says: "TypeError: weirdFunction is not a constructor”.
>>
>> exactly, because weirdFunction is actually https://tc39.github.io/ecma262/#sec-%iteratorprototype%-@@iterator which is a built-in function that is not identified as a constructor.
>>
>> https://tc39.github.io/ecma262/#sec-ecmascript-standard-built-in-objects says:
>> "Built-in function objects that are not identified [in this specification] as constructors do not implement the [[Construct]] internal method unless otherwise specified in the description of a particular function.”
>>
>> Step 7 of https://tc39.github.io/ecma262/#sec-evaluatenew says: If IsConstructor(constructor) is false, throw a TypeError exception.
>
> _______________________________________________
> 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/20160727/f345320a/attachment.html>
More information about the es-discuss
mailing list