ES6, access props set by the child from the parent's constructor
<p>I am trying to set up a class hierarchy with ES6 classes.</p>

<p>All entities will inherit from single <code>Base</code> class. It will need to access properties exposed by the <code>Child</code> class in a generic manner. Like this:</p>

<pre><code>class Base {
    constructor() {
        this.doSomethingWithProps();
    }

    doSomethingWithProps() {
        console.log(Object.keys(this));
    }
}

class Entity extends Base {
    constructor() {
        super();

        this.key = "value";
    }
}
</code></pre>

<p>Obviously, in the example above, <code>Base</code> class will not see the <code>key</code> prop set up by <code>Entity</code>. Ideally I would move the <code>this</code> assignment before <code>super()</code>, but that's not allowed. It would also be nice to be able to set properties before constructor, but AFAIK, that's not possible either.</p>

<p>The only solution I am left with is doing something like the following in each <code>Entity</code>:</p>

<pre><code>class Base {
    doSomethingWithProps() {
        console.log(Object.keys(this));
    }
}

class Entity extends Base {
    constructor() {
        super();

        this.key = "value";

        this.doSomethingWithProps();
    }
}
</code></pre>

<p>However, besides being less than ideal, it will also create problems if I then want to inherit from <code>Entity</code>. <code>doSomethingWithProps</code> would then need to be able to detect if it's the "top-most" method in call hierarchy and only do its thing then. The only way to achieve <em>that</em> (that I can think of) would involve <em>even more</em> boilerplate.</p>

<p>Is there some solution I'm missing here? I'd be open to using a different OOP pattern if needed, although I'd like to stay as close as possible to native ES6 classes.</p>