Jason Orendorff jason.orendorff at gmail.com
Tue Jun 17 13:02:28 PDT 2014

On Tue, Jun 17, 2014 at 2:49 PM, Jasper St. Pierre
<jstpierre at mecheye.net> wrote:
> How would
>     constructor() {
>         if (rand() > 0.5)
>             super("A");
>     }
> behave?


> We could prevent this behavior by making sure that super(); must be the
> first statement in a constructor, [...]

That is what I proposed.

> [...] but that means that the subclass can't
> really influence the parent constructor execution at all.

Any class can explicitly define a `static [Symbol.new]()` method, if desired.

Or the constructor method can return another object, so that the base
class @@new method is called, but the object it created is thrown
away. I should have mentioned that -- I would retain this behavior,
which is already in ES6, but none of the examples used it so I forgot
to say so.

Anyway --- skipping a base class constructor is not a normal thing to
do. It shouldn't be the default.


More information about the es-discuss mailing list