They diverge if a constructor makes a super-constructor call: The last 
constructor in a chain of super-constructor calls allocates the instance and it 
has to use `newTarget.prototype` as the prototype. `newTarget` is first filled 
in by the `new` operator and later passed on by `super`.

This is roughly similar to making super-method calls where `this` has to remain 
the same, because the super-method has to access the same instance properties.


> On 16 Mar 2015, at 18:32, Coolwust <[email protected]> wrote:
> 
> From ES 6, section 7.3.14, there is an abstract operation `Construct (F, 
> [argumentsList], [newTarget])`, so if I have the following code `var foo = 
> new bar()`, then `newTarget` is the same as `F`, which is `bar`. 
> 
> My question is, in what situation, `F` is **NOT** the same as `newTarget`? 
> And what is `newTarget` really?

-- 
Dr. Axel Rauschmayer
[email protected]
rauschma.de



_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to