constructor, super, and data members issue

Ranando King kingmph at
Fri Aug 24 20:52:12 UTC 2018

Aaron, congratulations! You just tripped over a new reason for me to revive
issue #123. The only way to get that to work is to have the default values
on the prototype. The problem comes because `this` doesn't even have a
value until the last call to `super()` returns. If a `class` doesn't have a
base `class` it essentially has Object as a base `class` and `super` is
implicitly called. So unless the default public field values are on the
prototype, there's literally no way to have them initialized before the
base classes are initialized.

On Fri, Aug 24, 2018 at 3:15 PM Aaron Gray <aaronngray.lists at>

> I am having an issue with order semantics regarding
> with derived classes
> defining or overriding data member values that are used in the base class
> constructor for initialization of properties of the class.
> This means the Super Class / Base Class'es constructor does not yet have
> access to the default field values of the derived class it is initiating.
>     class Base {
>         constructor() {
>              ....
>              .. idAttribute ..
>              ....
>         }
>         idAttribute = 'id';
>     }
>    class Derived extends Base {
>         constructor() {
>              super();
>              ....
>         }
>         idAttribute = '_id';
>    }
> All would mean having a separate initialize() function, but even this
> solution is flawed when there is a third level in the hierarchy. And as
> super() is required it means there seems to be no way round this issue. The
> only way I can see is some form of override keyword ?
> Has anyone got any solutions to this issue or work arounds ?
> --
> Aaron Gray
> Independent Open Source Software Engineer, Computer Language Researcher,
> Information Theorist, and amateur computer scientist.
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list