Code smell? Iterator prototype has iterator method that returns "this"

Allen Wirfs-Brock allen at
Wed Jul 27 15:12:46 UTC 2016

> On Jul 26, 2016, at 11:52 PM, Claude Pache <claude.pache at> wrote:
>> var weirdInstance = new weirdFunction(); // what is this??
>> ```
> My intuition says: "TypeError: weirdFunction is not a constructor”.

exactly, because weirdFunction is actually <> which is a built-in function that is not identified as a constructor. <> 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 <> says: If IsConstructor(constructor) is false, throw a TypeError exception.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list