What is the difference between `newTarget` and `F` in abstract operation `Construct(..)` ?

Axel Rauschmayer axel at rauschma.de
Mon Mar 16 17:55:52 UTC 2015

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 <coolwust at gmail.com> 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
axel at rauschma.de

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150316/b1af0b8b/attachment.html>

More information about the es-discuss mailing list