> Le 27 juil. 2016 à 08:56, Claude Pache <[email protected]> a écrit :
>
>
>> Le 27 juil. 2016 à 07:16, Jordan Harband <[email protected]> a écrit :
>>
>> `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).
>
> If `weirdFunction` were defined as if by evaluating `function () { return
> this }`, yes. But in general, functions are not necessarily constructors
> (just try `new Math.sin` in your favourite JS environment).
>
> —Claude
>
Correction: If `weirdFunction` were defined as if by evaluating `function () {
return this }`, **no**: in such a constructor (more precisely: when such a
function is used as a constructor), `this` is a brand-new "instance"; it can’t
be === to a previously existing object such as `iter`.
(Given how confusing and useless it is, I hope that my intuition ("not a
constructor") is correct.)
—Claude
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss